mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
CTDB: send drivename separately from userAgent
CTDB: include OS version in userAgent CTDB: send rip quality LAME: fix VBR options CTDB: optimize chienSearch
This commit is contained in:
@@ -376,24 +376,12 @@ namespace CUERipper
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
cueSheet.Go();
|
cueSheet.Go();
|
||||||
|
cueSheet.CTDB.Submit(
|
||||||
if ((cueSheet.CTDB.AccResult == HttpStatusCode.NotFound || cueSheet.CTDB.AccResult == HttpStatusCode.OK)
|
(int)cueSheet.ArVerify.WorstConfidence() + 1,
|
||||||
&& audioSource.CorrectionQuality > 0 && audioSource.ErrorsCount == 0)
|
audioSource.CorrectionQuality == 0 ? 0 :
|
||||||
{
|
100 - (int)(7 * Math.Log(audioSource.ErrorsCount + 1)), // ErrorsCount==1 ~= 95, ErrorsCount==max ~= 5;
|
||||||
DBEntry confirm = null;
|
cueSheet.Artist,
|
||||||
foreach (DBEntry entry in cueSheet.CTDB.Entries)
|
cueSheet.Title);
|
||||||
if (entry.toc.TrackOffsets == selectedDriveInfo.drive.TOC.TrackOffsets && !entry.hasErrors)
|
|
||||||
confirm = entry;
|
|
||||||
|
|
||||||
if (confirm != null)
|
|
||||||
cueSheet.CTDB.Confirm(confirm);
|
|
||||||
else
|
|
||||||
cueSheet.CTDB.Submit(
|
|
||||||
(int)cueSheet.ArVerify.WorstConfidence() + 1,
|
|
||||||
cueSheet.Artist,
|
|
||||||
cueSheet.Title);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool canFix = false;
|
bool canFix = false;
|
||||||
if (cueSheet.CTDB.AccResult == HttpStatusCode.OK && audioSource.ErrorsCount != 0)
|
if (cueSheet.CTDB.AccResult == HttpStatusCode.OK && audioSource.ErrorsCount != 0)
|
||||||
{
|
{
|
||||||
@@ -628,7 +616,7 @@ namespace CUERipper
|
|||||||
cueSheet.Action = CUEAction.Encode;
|
cueSheet.Action = CUEAction.Encode;
|
||||||
|
|
||||||
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " CTDB..."; });
|
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " CTDB..."; });
|
||||||
cueSheet.UseCUEToolsDB(true, "CUERipper " + CUESheet.CUEToolsVersion + ": " + selectedDriveInfo.drive.ARName);
|
cueSheet.UseCUEToolsDB(true, "CUERipper " + CUESheet.CUEToolsVersion, selectedDriveInfo.drive.ARName);
|
||||||
cueSheet.CTDB.UploadHelper.onProgress += new EventHandler<Krystalware.UploadHelper.UploadProgressEventArgs>(UploadProgress);
|
cueSheet.CTDB.UploadHelper.onProgress += new EventHandler<Krystalware.UploadHelper.UploadProgressEventArgs>(UploadProgress);
|
||||||
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " AccurateRip..."; });
|
this.BeginInvoke((MethodInvoker)delegate() { toolStripStatusLabel1.Text = Properties.Resources.LookingUpVia + " AccurateRip..."; });
|
||||||
cueSheet.UseAccurateRip();
|
cueSheet.UseAccurateRip();
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ namespace CUETools.AccurateRip
|
|||||||
|
|
||||||
// find offset
|
// find offset
|
||||||
fixed (byte* par2ptr = &parity2[pos])
|
fixed (byte* par2ptr = &parity2[pos])
|
||||||
|
fixed (ushort* chT = rs.chienTable)
|
||||||
{
|
{
|
||||||
ushort* par2 = (ushort*)par2ptr;
|
ushort* par2 = (ushort*)par2ptr;
|
||||||
int* _sigma = stackalloc int[npar];
|
int* _sigma = stackalloc int[npar];
|
||||||
@@ -354,7 +355,7 @@ namespace CUETools.AccurateRip
|
|||||||
err |= synI;
|
err |= synI;
|
||||||
}
|
}
|
||||||
int err_count = err == 0 ? 0 : rs.calcSigmaMBM(_sigma, syn);
|
int err_count = err == 0 ? 0 : rs.calcSigmaMBM(_sigma, syn);
|
||||||
if (err_count == allowed_errors && (err_count == 0 || rs.chienSearch(_errpos, stridecount + npar, err_count, _sigma)))
|
if (err_count == allowed_errors && (err_count == 0 || rs.chienSearch(_errpos, stridecount + npar, err_count, _sigma, chT)))
|
||||||
{
|
{
|
||||||
actualOffset = offset;
|
actualOffset = offset;
|
||||||
hasErrors = err_count != 0 || ar.CTDBCRC(-offset) != expectedCRC;
|
hasErrors = err_count != 0 || ar.CTDBCRC(-offset) != expectedCRC;
|
||||||
@@ -386,7 +387,8 @@ namespace CUETools.AccurateRip
|
|||||||
fix.errors = new int[stride];
|
fix.errors = new int[stride];
|
||||||
|
|
||||||
fixed (byte* par = &parity2[pos])
|
fixed (byte* par = &parity2[pos])
|
||||||
fixed (ushort* exp = galois.ExpTbl, log = galois.LogTbl)
|
fixed (ushort* exp = galois.ExpTbl, log = galois.LogTbl, chT = rs.chienTable)
|
||||||
|
fixed (int* sf = fix.sigma, of = fix.omega, ef = fix.errpos)
|
||||||
{
|
{
|
||||||
int* syn = stackalloc int[npar];
|
int* syn = stackalloc int[npar];
|
||||||
int offset = fix.actualOffset;
|
int offset = fix.actualOffset;
|
||||||
@@ -437,12 +439,15 @@ namespace CUETools.AccurateRip
|
|||||||
|
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
fixed (int* s = &fix.sigma[part, 0], o = &fix.omega[part, 0], e = &fix.errpos[part, 0])
|
int* s = sf + part * fix.sigma.GetLength(1);
|
||||||
|
int* o = of + part * fix.omega.GetLength(1);
|
||||||
|
int* e = ef + part * fix.errpos.GetLength(1);
|
||||||
|
//fixed (int* s = &fix.sigma[part, 0], o = &fix.omega[part, 0], e = &fix.errpos[part, 0])
|
||||||
{
|
{
|
||||||
fix.errors[part] = rs.calcSigmaMBM(s, syn);
|
fix.errors[part] = rs.calcSigmaMBM(s, syn);
|
||||||
fix.hasErrors = true;
|
fix.hasErrors = true;
|
||||||
fix.correctableErrors += fix.errors[part];
|
fix.correctableErrors += fix.errors[part];
|
||||||
if (fix.errors[part] <= 0 || !rs.chienSearch(e, stridecount + npar, fix.errors[part], s))
|
if (fix.errors[part] <= 0 || !rs.chienSearch(e, stridecount + npar, fix.errors[part], s, chT))
|
||||||
fix.canRecover = false;
|
fix.canRecover = false;
|
||||||
else
|
else
|
||||||
galois.mulPoly(o, s, syn, npar / 2 + 1, npar, npar);
|
galois.mulPoly(o, s, syn, npar / 2 + 1, npar, npar);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
<Reference Include="Interop.HelperFunctionsLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Interop.HelperFunctionsLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>.\Interop.HelperFunctionsLib.dll</HintPath>
|
<HintPath>.\Interop.HelperFunctionsLib.dll</HintPath>
|
||||||
|
<Private>False</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace AudioDataPlugIn
|
|||||||
#if USEAR
|
#if USEAR
|
||||||
ar.ContactAccurateRip(ArId);
|
ar.ContactAccurateRip(ArId);
|
||||||
#endif
|
#endif
|
||||||
ctdb.ContactDB("EAC" + m_data.HostVersion + " CTDB 2.1.1: " + m_drivename);
|
ctdb.ContactDB("EAC" + m_data.HostVersion + " CTDB 2.1.1", m_drivename);
|
||||||
ctdb.Init(true, ar);
|
ctdb.Init(true, ar);
|
||||||
this.sequence_ok = true;
|
this.sequence_ok = true;
|
||||||
this.m_start_pos = 0;
|
this.m_start_pos = 0;
|
||||||
@@ -241,33 +241,20 @@ namespace AudioDataPlugIn
|
|||||||
return "";
|
return "";
|
||||||
if (this.sequence_ok)
|
if (this.sequence_ok)
|
||||||
{
|
{
|
||||||
bool is_accurate = (arTest.Position == 0 && this.is_secure_mode) || arTest.CRC32(0) == ar.CRC32(0);
|
ctdb.DoVerify();
|
||||||
DBEntry confirm = null;
|
ctdb.Submit(
|
||||||
if (ctdb.AccResult == HttpStatusCode.OK)
|
|
||||||
ctdb.DoVerify();
|
|
||||||
if ((ctdb.AccResult == HttpStatusCode.NotFound || ctdb.AccResult == HttpStatusCode.OK)
|
|
||||||
&& is_accurate)
|
|
||||||
{
|
|
||||||
foreach (DBEntry entry in ctdb.Entries)
|
|
||||||
if (entry.toc.TrackOffsets == TOC.TrackOffsets && !entry.hasErrors)
|
|
||||||
confirm = entry;
|
|
||||||
|
|
||||||
if (confirm != null)
|
|
||||||
ctdb.Confirm(confirm);
|
|
||||||
else
|
|
||||||
ctdb.Submit(
|
|
||||||
#if USEAR
|
#if USEAR
|
||||||
(int)ar.WorstConfidence() + 1,
|
(int)ar.WorstConfidence() + 1,
|
||||||
#else
|
#else
|
||||||
1,
|
1,
|
||||||
#endif
|
#endif
|
||||||
m_data.AlbumArtist,
|
(arTest.Position == 0 && this.is_secure_mode) || arTest.CRC32(0) == ar.CRC32(0) ? 100 : 0,
|
||||||
m_data.AlbumTitle);
|
m_data.AlbumArtist,
|
||||||
}
|
m_data.AlbumTitle);
|
||||||
sw.WriteLine("[CTDB TOCID: {0}] {1}{2}.",
|
sw.WriteLine("[CTDB TOCID: {0}] {1}{2}.",
|
||||||
TOC.TOCID,
|
TOC.TOCID,
|
||||||
ctdb.DBStatus ?? "found",
|
ctdb.DBStatus ?? "found",
|
||||||
(confirm != null || ctdb.SubStatus == null) ? "" : (", Submit result: " + ctdb.SubStatus));
|
(ctdb.SubStatus == null) ? "" : (", Submit result: " + ctdb.SubStatus));
|
||||||
foreach (DBEntry entry in ctdb.Entries)
|
foreach (DBEntry entry in ctdb.Entries)
|
||||||
{
|
{
|
||||||
string confFormat = (ctdb.Total < 10) ? "{0:0}/{1:0}" :
|
string confFormat = (ctdb.Total < 10) ? "{0:0}/{1:0}" :
|
||||||
@@ -284,14 +271,13 @@ namespace AudioDataPlugIn
|
|||||||
entry.canRecover ? string.Format("Differs in {0} samples @{1}", entry.repair.CorrectableErrors, entry.repair.AffectedSectors) :
|
entry.canRecover ? string.Format("Differs in {0} samples @{1}", entry.repair.CorrectableErrors, entry.repair.AffectedSectors) :
|
||||||
(entry.httpStatus == 0 || entry.httpStatus == HttpStatusCode.OK) ? "No match" :
|
(entry.httpStatus == 0 || entry.httpStatus == HttpStatusCode.OK) ? "No match" :
|
||||||
entry.httpStatus.ToString());
|
entry.httpStatus.ToString());
|
||||||
sw.WriteLine("[{0:x8}] ({1}) {2}{3}",
|
sw.WriteLine("[{0:x8}] ({1}) {2}",
|
||||||
entry.crc,
|
entry.crc,
|
||||||
conf,
|
conf,
|
||||||
status,
|
status);
|
||||||
(confirm != entry || ctdb.SubStatus == null) ? "" : (", Submit result: " + ctdb.SubStatus));
|
|
||||||
}
|
}
|
||||||
bool canFix = false;
|
bool canFix = false;
|
||||||
if (ctdb.AccResult == HttpStatusCode.OK && !is_accurate)
|
if (ctdb.AccResult == HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
foreach (DBEntry entry in ctdb.Entries)
|
foreach (DBEntry entry in ctdb.Entries)
|
||||||
if (entry.hasErrors && entry.canRecover)
|
if (entry.hasErrors && entry.canRecover)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace CUETools.CTDB
|
|||||||
{
|
{
|
||||||
const string urlbase = "http://db.cuetools.net";
|
const string urlbase = "http://db.cuetools.net";
|
||||||
string userAgent;
|
string userAgent;
|
||||||
|
string driveName;
|
||||||
|
|
||||||
private CDRepairEncode verify;
|
private CDRepairEncode verify;
|
||||||
private CDImageLayout toc;
|
private CDImageLayout toc;
|
||||||
@@ -38,9 +39,10 @@ namespace CUETools.CTDB
|
|||||||
this.uploadHelper = new HttpUploadHelper();
|
this.uploadHelper = new HttpUploadHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ContactDB(string userAgent)
|
public void ContactDB(string userAgent, string driveName)
|
||||||
{
|
{
|
||||||
this.userAgent = userAgent;
|
this.driveName = driveName;
|
||||||
|
this.userAgent = userAgent + " (" + Environment.OSVersion.VersionString + ")" + (driveName != null ? " (" + driveName + ")" : "");
|
||||||
this.total = 0;
|
this.total = 0;
|
||||||
|
|
||||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlbase + "/lookup.php?tocid=" + toc.TOCID);
|
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(urlbase + "/lookup.php?tocid=" + toc.TOCID);
|
||||||
@@ -184,17 +186,22 @@ namespace CUETools.CTDB
|
|||||||
return uuidInfo;
|
return uuidInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Confirm(DBEntry entry)
|
public string Submit(int confidence, int quality, string artist, string title)
|
||||||
{
|
{
|
||||||
return Submit(1, null, null, !entry.hasParity /*&& entry.conf > 100*/, true, entry.id);
|
if (this.AccResult != HttpStatusCode.NotFound && this.AccResult != HttpStatusCode.OK)
|
||||||
|
return this.DBStatus;
|
||||||
|
DBEntry confirm = null;
|
||||||
|
foreach (DBEntry entry in this.Entries)
|
||||||
|
if (entry.toc.TrackOffsets == this.toc.TrackOffsets && !entry.hasErrors)
|
||||||
|
confirm = entry;
|
||||||
|
if (confirm != null) confidence = 1;
|
||||||
|
DoSubmit(confidence, quality, artist, title, false, confirm);
|
||||||
|
if (subResult == "parity needed")
|
||||||
|
DoSubmit(confidence, quality, artist, title, true, confirm);
|
||||||
|
return subResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Submit(int confidence, string artist, string title)
|
protected string DoSubmit(int confidence, int quality, string artist, string title, bool upload, DBEntry confirm)
|
||||||
{
|
|
||||||
return Submit(confidence, artist, title, confidence > 1, false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Submit(int confidence, string artist, string title, bool upload, bool confirm, string confirmid)
|
|
||||||
{
|
{
|
||||||
UploadFile[] files;
|
UploadFile[] files;
|
||||||
if (upload)
|
if (upload)
|
||||||
@@ -229,8 +236,8 @@ namespace CUETools.CTDB
|
|||||||
NameValueCollection form = new NameValueCollection();
|
NameValueCollection form = new NameValueCollection();
|
||||||
if (upload)
|
if (upload)
|
||||||
form.Add("parityfile", "1");
|
form.Add("parityfile", "1");
|
||||||
if (confirm)
|
if (confirm != null)
|
||||||
form.Add("confirmid", confirmid);
|
form.Add("confirmid", confirm.id);
|
||||||
form.Add("tocid", toc.TOCID);
|
form.Add("tocid", toc.TOCID);
|
||||||
form.Add("crc32", ((int)verify.CRC).ToString());
|
form.Add("crc32", ((int)verify.CRC).ToString());
|
||||||
form.Add("trackcrcs", verify.TrackCRCs);
|
form.Add("trackcrcs", verify.TrackCRCs);
|
||||||
@@ -241,6 +248,9 @@ namespace CUETools.CTDB
|
|||||||
form.Add("audiotracks", toc.AudioTracks.ToString());
|
form.Add("audiotracks", toc.AudioTracks.ToString());
|
||||||
form.Add("trackoffsets", toc.TrackOffsets);
|
form.Add("trackoffsets", toc.TrackOffsets);
|
||||||
form.Add("userid", GetUUID());
|
form.Add("userid", GetUUID());
|
||||||
|
form.Add("quality", quality.ToString());
|
||||||
|
if (driveName != null)
|
||||||
|
form.Add("drivename", driveName);
|
||||||
if (artist != null && artist != "") form.Add("artist", artist);
|
if (artist != null && artist != "") form.Add("artist", artist);
|
||||||
if (title != null && title != "") form.Add("title", title);
|
if (title != null && title != "") form.Add("title", title);
|
||||||
|
|
||||||
@@ -340,6 +350,8 @@ namespace CUETools.CTDB
|
|||||||
|
|
||||||
public void DoVerify()
|
public void DoVerify()
|
||||||
{
|
{
|
||||||
|
if (this.AccResult != HttpStatusCode.OK)
|
||||||
|
return;
|
||||||
foreach (DBEntry entry in entries)
|
foreach (DBEntry entry in entries)
|
||||||
{
|
{
|
||||||
if (entry.toc.Pregap != toc.Pregap || entry.toc.AudioLength != toc.AudioLength || entry.stride != verify.Stride / 2)
|
if (entry.toc.Pregap != toc.Pregap || entry.toc.AudioLength != toc.AudioLength || entry.stride != verify.Stride / 2)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
|
|
||||||
protected virtual BE_CONFIG MakeConfig()
|
protected virtual BE_CONFIG MakeConfig()
|
||||||
{
|
{
|
||||||
return new BE_CONFIG(_pcm, 128);
|
return new BE_CONFIG(_pcm);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool inited = false;
|
private bool inited = false;
|
||||||
@@ -121,7 +121,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
throw new ApplicationException(string.Format("Lame_encDll.beInitStream failed with the error code {0}", LameResult));
|
throw new ApplicationException(string.Format("Lame_encDll.beInitStream failed with the error code {0}", LameResult));
|
||||||
|
|
||||||
m_InBuffer = new byte[m_InputSamples * 2]; //Input buffer is expected as short[]
|
m_InBuffer = new byte[m_InputSamples * 2]; //Input buffer is expected as short[]
|
||||||
m_OutBuffer = new byte[m_OutBufferSize];
|
m_OutBuffer = new byte[Math.Max(65536, m_OutBufferSize)];
|
||||||
|
|
||||||
if (_IO == null)
|
if (_IO == null)
|
||||||
_IO = new FileStream(_path, FileMode.Create, FileAccess.Write, FileShare.Read);
|
_IO = new FileStream(_path, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||||
@@ -129,7 +129,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(AudioBuffer buff)
|
public unsafe void Write(AudioBuffer buff)
|
||||||
{
|
{
|
||||||
buff.Prepare(this);
|
buff.Prepare(this);
|
||||||
|
|
||||||
@@ -142,60 +142,76 @@ namespace CUETools.Codecs.LAME
|
|||||||
int ToCopy = 0;
|
int ToCopy = 0;
|
||||||
uint EncodedSize = 0;
|
uint EncodedSize = 0;
|
||||||
uint LameResult;
|
uint LameResult;
|
||||||
while (count > 0)
|
uint outBufferIndex = 0;
|
||||||
|
fixed (byte* pBuffer = buffer, pOutBuffer = m_OutBuffer)
|
||||||
{
|
{
|
||||||
if (m_InBufferPos > 0)
|
while (count > 0)
|
||||||
{
|
{
|
||||||
ToCopy = Math.Min(count, m_InBuffer.Length - m_InBufferPos);
|
if (m_InBufferPos > 0)
|
||||||
Buffer.BlockCopy(buffer, index, m_InBuffer, m_InBufferPos, ToCopy);
|
|
||||||
m_InBufferPos += ToCopy;
|
|
||||||
index += ToCopy;
|
|
||||||
count -= ToCopy;
|
|
||||||
if (m_InBufferPos >= m_InBuffer.Length)
|
|
||||||
{
|
{
|
||||||
m_InBufferPos = 0;
|
ToCopy = Math.Min(count, m_InBuffer.Length - m_InBufferPos);
|
||||||
if ((LameResult = Lame_encDll.EncodeChunk(m_hLameStream, m_InBuffer, m_OutBuffer, ref EncodedSize)) == Lame_encDll.BE_ERR_SUCCESSFUL)
|
Buffer.BlockCopy(buffer, index, m_InBuffer, m_InBufferPos, ToCopy);
|
||||||
|
m_InBufferPos += ToCopy;
|
||||||
|
index += ToCopy;
|
||||||
|
count -= ToCopy;
|
||||||
|
if (m_InBufferPos >= m_InBuffer.Length)
|
||||||
{
|
{
|
||||||
if (EncodedSize > 0)
|
m_InBufferPos = 0;
|
||||||
|
if (outBufferIndex > 0)
|
||||||
{
|
{
|
||||||
_IO.Write(m_OutBuffer, 0, (int)EncodedSize);
|
_IO.Write(m_OutBuffer, 0, (int)outBufferIndex);
|
||||||
bytesWritten += EncodedSize;
|
bytesWritten += outBufferIndex;
|
||||||
|
outBufferIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((LameResult = Lame_encDll.EncodeChunk(m_hLameStream, m_InBuffer, m_OutBuffer, ref EncodedSize)) == Lame_encDll.BE_ERR_SUCCESSFUL)
|
||||||
|
{
|
||||||
|
outBufferIndex += EncodedSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ApplicationException(string.Format("Lame_encDll.EncodeChunk failed with the error code {0}", LameResult));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ApplicationException(string.Format("Lame_encDll.EncodeChunk failed with the error code {0}", LameResult));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (count >= m_InBuffer.Length)
|
|
||||||
{
|
|
||||||
if ((LameResult = Lame_encDll.EncodeChunk(m_hLameStream, buffer, index, (uint)m_InBuffer.Length, m_OutBuffer, ref EncodedSize)) == Lame_encDll.BE_ERR_SUCCESSFUL)
|
|
||||||
{
|
|
||||||
if (EncodedSize > 0)
|
|
||||||
{
|
|
||||||
_IO.Write(m_OutBuffer, 0, (int)EncodedSize);
|
|
||||||
bytesWritten += EncodedSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new ApplicationException(string.Format("Lame_encDll.EncodeChunk failed with the error code {0}", LameResult));
|
|
||||||
}
|
|
||||||
count -= m_InBuffer.Length;
|
|
||||||
index += m_InBuffer.Length;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Buffer.BlockCopy(buffer, index, m_InBuffer, 0, count);
|
if (count >= m_InBuffer.Length)
|
||||||
m_InBufferPos = count;
|
{
|
||||||
index += count;
|
if (outBufferIndex + m_OutBufferSize > m_OutBuffer.Length)
|
||||||
count = 0;
|
{
|
||||||
|
_IO.Write(m_OutBuffer, 0, (int)outBufferIndex);
|
||||||
|
bytesWritten += outBufferIndex;
|
||||||
|
outBufferIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((LameResult = Lame_encDll.EncodeChunk(m_hLameStream, pBuffer + index, (uint)m_InBuffer.Length, pOutBuffer + outBufferIndex, ref EncodedSize)) == Lame_encDll.BE_ERR_SUCCESSFUL)
|
||||||
|
{
|
||||||
|
outBufferIndex += EncodedSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new ApplicationException(string.Format("Lame_encDll.EncodeChunk failed with the error code {0}", LameResult));
|
||||||
|
}
|
||||||
|
count -= m_InBuffer.Length;
|
||||||
|
index += m_InBuffer.Length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Buffer.BlockCopy(buffer, index, m_InBuffer, 0, count);
|
||||||
|
m_InBufferPos = count;
|
||||||
|
index += count;
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outBufferIndex > 0)
|
||||||
|
{
|
||||||
|
_IO.Write(m_OutBuffer, 0, (int)outBufferIndex);
|
||||||
|
bytesWritten += outBufferIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int CompressionLevel
|
public virtual int CompressionLevel
|
||||||
@@ -264,10 +280,23 @@ namespace CUETools.Codecs.LAME
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum LAMEEncoderVBRProcessingQuality : uint
|
||||||
|
{
|
||||||
|
Best = 0,
|
||||||
|
Normal = 5,
|
||||||
|
}
|
||||||
|
|
||||||
public class LAMEEncoderVBRSettings
|
public class LAMEEncoderVBRSettings
|
||||||
{
|
{
|
||||||
public LAMEEncoderVBRSettings() { }
|
public LAMEEncoderVBRSettings()
|
||||||
|
{
|
||||||
|
// Iterate through each property and call ResetValue()
|
||||||
|
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this))
|
||||||
|
property.ResetValue(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DefaultValue(LAMEEncoderVBRProcessingQuality.Normal)]
|
||||||
|
public LAMEEncoderVBRProcessingQuality Quality { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[AudioEncoderClass("lame VBR", "mp3", false, "V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2", 2, typeof(LAMEEncoderVBRSettings))]
|
[AudioEncoderClass("lame VBR", "mp3", false, "V9 V8 V7 V6 V5 V4 V3 V2 V1 V0", "V2", 2, typeof(LAMEEncoderVBRSettings))]
|
||||||
@@ -287,7 +316,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
|
|
||||||
protected override BE_CONFIG MakeConfig()
|
protected override BE_CONFIG MakeConfig()
|
||||||
{
|
{
|
||||||
BE_CONFIG Mp3Config = new BE_CONFIG(PCM, 128);
|
BE_CONFIG Mp3Config = new BE_CONFIG(PCM, 0, (uint)_settings.Quality);
|
||||||
Mp3Config.format.lhv1.bWriteVBRHeader = 1;
|
Mp3Config.format.lhv1.bWriteVBRHeader = 1;
|
||||||
Mp3Config.format.lhv1.nMode = MpegMode.JOINT_STEREO;
|
Mp3Config.format.lhv1.nMode = MpegMode.JOINT_STEREO;
|
||||||
Mp3Config.format.lhv1.bEnableVBR = 1;
|
Mp3Config.format.lhv1.bEnableVBR = 1;
|
||||||
@@ -391,7 +420,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
|
|
||||||
protected override BE_CONFIG MakeConfig()
|
protected override BE_CONFIG MakeConfig()
|
||||||
{
|
{
|
||||||
BE_CONFIG Mp3Config = new BE_CONFIG(PCM, _settings.CustomBitrate > 0 ? (uint)_settings.CustomBitrate : bps);
|
BE_CONFIG Mp3Config = new BE_CONFIG(PCM, _settings.CustomBitrate > 0 ? (uint)_settings.CustomBitrate : bps, 5);
|
||||||
Mp3Config.format.lhv1.bWriteVBRHeader = 1;
|
Mp3Config.format.lhv1.bWriteVBRHeader = 1;
|
||||||
Mp3Config.format.lhv1.nMode = _settings.StereoMode;
|
Mp3Config.format.lhv1.nMode = _settings.StereoMode;
|
||||||
//Mp3Config.format.lhv1.nVbrMethod = VBRMETHOD.VBR_METHOD_NONE; // --cbr
|
//Mp3Config.format.lhv1.nVbrMethod = VBRMETHOD.VBR_METHOD_NONE; // --cbr
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
//[ MarshalAs( UnmanagedType.ByValArray, SizeConst=255-4*4-2 )]
|
//[ MarshalAs( UnmanagedType.ByValArray, SizeConst=255-4*4-2 )]
|
||||||
//public byte[] btReserved;//[255-4*sizeof(DWORD) - sizeof( WORD )];
|
//public byte[] btReserved;//[255-4*sizeof(DWORD) - sizeof( WORD )];
|
||||||
|
|
||||||
public LHV1(AudioPCMConfig format, uint MpeBitRate)
|
public LHV1(AudioPCMConfig format, uint MpeBitRate, uint quality)
|
||||||
{
|
{
|
||||||
dwStructVersion = 1;
|
dwStructVersion = 1;
|
||||||
dwStructSize = (uint)Marshal.SizeOf(typeof(BE_CONFIG));
|
dwStructSize = (uint)Marshal.SizeOf(typeof(BE_CONFIG));
|
||||||
@@ -171,6 +171,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
}
|
}
|
||||||
switch (MpeBitRate)
|
switch (MpeBitRate)
|
||||||
{
|
{
|
||||||
|
case 0 :
|
||||||
case 32 :
|
case 32 :
|
||||||
case 40 :
|
case 40 :
|
||||||
case 48 :
|
case 48 :
|
||||||
@@ -217,7 +218,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
bStrictIso = 0;
|
bStrictIso = 0;
|
||||||
dwMaxBitrate = 0;
|
dwMaxBitrate = 0;
|
||||||
dwVbrAbr_bps = 0;
|
dwVbrAbr_bps = 0;
|
||||||
nQuality = 0;
|
nQuality = (ushort)(quality | ((~quality) << 8));
|
||||||
nVbrMethod = VBRMETHOD.VBR_METHOD_NONE;
|
nVbrMethod = VBRMETHOD.VBR_METHOD_NONE;
|
||||||
nVBRQuality = 0;
|
nVBRQuality = 0;
|
||||||
}
|
}
|
||||||
@@ -243,9 +244,9 @@ namespace CUETools.Codecs.LAME
|
|||||||
[FieldOffset(0)]
|
[FieldOffset(0)]
|
||||||
public ACC acc;
|
public ACC acc;
|
||||||
|
|
||||||
public Format(AudioPCMConfig format, uint MpeBitRate)
|
public Format(AudioPCMConfig format, uint MpeBitRate, uint quality)
|
||||||
{
|
{
|
||||||
lhv1 = new LHV1(format, MpeBitRate);
|
lhv1 = new LHV1(format, MpeBitRate, quality);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,13 +260,13 @@ namespace CUETools.Codecs.LAME
|
|||||||
public uint dwConfig;
|
public uint dwConfig;
|
||||||
public Format format;
|
public Format format;
|
||||||
|
|
||||||
public BE_CONFIG(AudioPCMConfig format, uint MpeBitRate)
|
public BE_CONFIG(AudioPCMConfig format, uint MpeBitRate, uint quality)
|
||||||
{
|
{
|
||||||
this.dwConfig = BE_CONFIG_LAME;
|
this.dwConfig = BE_CONFIG_LAME;
|
||||||
this.format = new Format(format, MpeBitRate);
|
this.format = new Format(format, MpeBitRate, quality);
|
||||||
}
|
}
|
||||||
public BE_CONFIG(AudioPCMConfig format)
|
public BE_CONFIG(AudioPCMConfig format)
|
||||||
: this(format, 128)
|
: this(format, 0, 5)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,7 +357,7 @@ namespace CUETools.Codecs.LAME
|
|||||||
/// The amount of data written might vary from chunk to chunk</param>
|
/// The amount of data written might vary from chunk to chunk</param>
|
||||||
/// <returns>On success: BE_ERR_SUCCESSFUL</returns>
|
/// <returns>On success: BE_ERR_SUCCESSFUL</returns>
|
||||||
[DllImport("Lame_enc.dll")]
|
[DllImport("Lame_enc.dll")]
|
||||||
protected static extern uint beEncodeChunk(uint hbeStream, uint nSamples, IntPtr pSamples, [In, Out] byte[] pOutput, ref uint pdwOutput);
|
protected static extern uint beEncodeChunk(uint hbeStream, uint nSamples, IntPtr pSamples, IntPtr pOutput, ref uint pdwOutput);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encodes a chunk of samples. Samples are contained in a byte array
|
/// Encodes a chunk of samples. Samples are contained in a byte array
|
||||||
@@ -370,20 +371,27 @@ namespace CUETools.Codecs.LAME
|
|||||||
/// <param name="pdwOutput">Returns the number of bytes of encoded data written.
|
/// <param name="pdwOutput">Returns the number of bytes of encoded data written.
|
||||||
/// The amount of data written might vary from chunk to chunk</param>
|
/// The amount of data written might vary from chunk to chunk</param>
|
||||||
/// <returns>On success: BE_ERR_SUCCESSFUL</returns>
|
/// <returns>On success: BE_ERR_SUCCESSFUL</returns>
|
||||||
public static uint EncodeChunk(uint hbeStream, byte[] buffer, int index, uint nBytes, byte[] pOutput, ref uint pdwOutput)
|
public static unsafe uint EncodeChunk(uint hbeStream, byte *pSamples, uint nBytes, byte* pOutput, ref uint pdwOutput)
|
||||||
{
|
{
|
||||||
uint res;
|
return beEncodeChunk(hbeStream, nBytes / 2/*Samples*/, (IntPtr)pSamples, (IntPtr)pOutput, ref pdwOutput);
|
||||||
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
}
|
||||||
try
|
|
||||||
{
|
/// <summary>
|
||||||
IntPtr ptr = (IntPtr)(handle.AddrOfPinnedObject().ToInt32()+index);
|
/// Encodes a chunk of samples. Samples are contained in a byte array
|
||||||
res = beEncodeChunk(hbeStream, nBytes/2/*Samples*/, ptr, pOutput, ref pdwOutput);
|
/// </summary>
|
||||||
}
|
/// <param name="hbeStream">Handle of the stream.</param>
|
||||||
finally
|
/// <param name="buffer">Bytes to encode</param>
|
||||||
{
|
/// <param name="index">Position of the first byte to encode</param>
|
||||||
handle.Free();
|
/// <param name="nBytes">Number of bytes to encode (not samples, samples are two byte lenght)</param>
|
||||||
}
|
/// <param name="pOutput">Buffer where to write the encoded data.
|
||||||
return res;
|
/// This buffer should be at least of the minimum size returned by beInitStream().</param>
|
||||||
|
/// <param name="pdwOutput">Returns the number of bytes of encoded data written.
|
||||||
|
/// The amount of data written might vary from chunk to chunk</param>
|
||||||
|
/// <returns>On success: BE_ERR_SUCCESSFUL</returns>
|
||||||
|
public static unsafe uint EncodeChunk(uint hbeStream, byte[] Samples, int index, uint nBytes, byte[] Output, ref uint pdwOutput)
|
||||||
|
{
|
||||||
|
fixed(byte *pSamples = &Samples[index], pOutput = Output)
|
||||||
|
return beEncodeChunk(hbeStream, nBytes / 2/*Samples*/, (IntPtr)pSamples, (IntPtr)pOutput, ref pdwOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -3191,13 +3191,13 @@ string status = processor.Go();
|
|||||||
_padding += _eacLog.Length;
|
_padding += _eacLog.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseCUEToolsDB(bool submit, string userAgent)
|
public void UseCUEToolsDB(bool submit, string userAgent, string driveName)
|
||||||
{
|
{
|
||||||
ShowProgress((string)"Contacting CUETools database...", 0, null, null);
|
ShowProgress((string)"Contacting CUETools database...", 0, null, null);
|
||||||
|
|
||||||
_CUEToolsDB = new CUEToolsDB(_toc, proxy);
|
_CUEToolsDB = new CUEToolsDB(_toc, proxy);
|
||||||
_CUEToolsDB.UploadHelper.onProgress += new EventHandler<Krystalware.UploadHelper.UploadProgressEventArgs>(UploadProgress);
|
_CUEToolsDB.UploadHelper.onProgress += new EventHandler<Krystalware.UploadHelper.UploadProgressEventArgs>(UploadProgress);
|
||||||
_CUEToolsDB.ContactDB(userAgent);
|
_CUEToolsDB.ContactDB(userAgent, driveName);
|
||||||
|
|
||||||
if (!_toc[_toc.TrackCount].IsAudio && DataTrackLength == 0)
|
if (!_toc[_toc.TrackCount].IsAudio && DataTrackLength == 0)
|
||||||
foreach (DBEntry e in _CUEToolsDB.Entries)
|
foreach (DBEntry e in _CUEToolsDB.Entries)
|
||||||
@@ -4325,11 +4325,8 @@ string status = processor.Go();
|
|||||||
else if (_audioEncoderType != AudioEncoderType.NoAudio)
|
else if (_audioEncoderType != AudioEncoderType.NoAudio)
|
||||||
WriteAudioFilesPass(OutputDir, OutputStyle, destLengths, htoaToFile, _action == CUEAction.Verify);
|
WriteAudioFilesPass(OutputDir, OutputStyle, destLengths, htoaToFile, _action == CUEAction.Verify);
|
||||||
|
|
||||||
if (_useCUEToolsDB && _CUEToolsDB.AccResult == HttpStatusCode.OK)
|
if (_useCUEToolsDB && !_useCUEToolsDBFix)
|
||||||
{
|
_CUEToolsDB.DoVerify();
|
||||||
if (!_useCUEToolsDBFix)
|
|
||||||
_CUEToolsDB.DoVerify();
|
|
||||||
}
|
|
||||||
|
|
||||||
_processed = true;
|
_processed = true;
|
||||||
|
|
||||||
@@ -6311,17 +6308,17 @@ string status = processor.Go();
|
|||||||
foreach (DBEntry entry in CTDB.Entries)
|
foreach (DBEntry entry in CTDB.Entries)
|
||||||
if (entry.toc.TrackOffsets == _toc.TrackOffsets && !entry.hasErrors)
|
if (entry.toc.TrackOffsets == _toc.TrackOffsets && !entry.hasErrors)
|
||||||
return "CUEToolsDB: " + CTDB.Status;
|
return "CUEToolsDB: " + CTDB.Status;
|
||||||
if (ArVerify.WorstConfidence() < 2)
|
if (ArVerify.WorstConfidence() < 1)
|
||||||
{
|
{
|
||||||
CTDB.SubStatus = "will not submit";
|
CTDB.SubStatus = "will not submit";
|
||||||
return GenerateAccurateRipStatus();
|
return GenerateAccurateRipStatus();
|
||||||
}
|
}
|
||||||
CTDB.Submit((int)ArVerify.WorstConfidence(), Artist, Title);
|
CTDB.Submit((int)ArVerify.WorstConfidence(), 100, Artist, Title);
|
||||||
return GenerateAccurateRipStatus();
|
return GenerateAccurateRipStatus();
|
||||||
}
|
}
|
||||||
case "repair":
|
case "repair":
|
||||||
{
|
{
|
||||||
UseCUEToolsDB(false, "CUETools " + CUEToolsVersion);
|
UseCUEToolsDB(false, "CUETools " + CUEToolsVersion, null);
|
||||||
Action = CUEAction.Verify;
|
Action = CUEAction.Verify;
|
||||||
if (CTDB.DBStatus != null)
|
if (CTDB.DBStatus != null)
|
||||||
return CTDB.DBStatus;
|
return CTDB.DBStatus;
|
||||||
|
|||||||
@@ -873,7 +873,7 @@ namespace JDP {
|
|||||||
if (useLocalDB)
|
if (useLocalDB)
|
||||||
cueSheet.UseLocalDB(_localDB);
|
cueSheet.UseLocalDB(_localDB);
|
||||||
if (useCUEToolsDB)
|
if (useCUEToolsDB)
|
||||||
cueSheet.UseCUEToolsDB(false, "CUETools " + CUESheet.CUEToolsVersion);
|
cueSheet.UseCUEToolsDB(false, "CUETools " + CUESheet.CUEToolsVersion, null);
|
||||||
if (useAR)
|
if (useAR)
|
||||||
cueSheet.UseAccurateRip();
|
cueSheet.UseAccurateRip();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user