mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-05-07 21:07:13 +02:00
added first draft of Philips "Repair/ChannelList/s2channellib/*.dat" loader.
currently supports: - read and write of satellite channels (incl. sorted favorites and "locked" flag) - read-only of digital cable/antenna files (still missing transponder information)
This commit is contained in:
@@ -49,8 +49,8 @@ namespace ChanSort.Api
|
||||
this.Warnings.AppendFormat("Duplicate transponder data record for satellite #{0} with id {1}\r\n", sat?.Id, trans.Id);
|
||||
return;
|
||||
}
|
||||
if (sat != null)
|
||||
sat.Transponder.Add(trans.Id, trans);
|
||||
|
||||
sat?.Transponder.Add(trans.Id, trans);
|
||||
this.Transponder.Add(trans.Id, trans);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
// To get the same CRC32 values that an LSB-first implementation would produce,
|
||||
// all bits in the input bytes, the polynomial (=> 0xEDB88320) and the resulting crc need to be reversed (msb to lsb)
|
||||
|
||||
public const uint NormalPoly = 0x04C11DB7;
|
||||
public const uint ReversedPoly = 0xEDB88320;
|
||||
private const uint CrcMask = 0xFFFFFFFF;
|
||||
private const uint CrcPoly = 0x04C11DB7;
|
||||
|
||||
public static Crc32 Normal = new Crc32(true);
|
||||
public static Crc32 Reversed = new Crc32(false);
|
||||
public static Crc32 Normal = new Crc32(true, NormalPoly);
|
||||
public static Crc32 Reversed = new Crc32(false, NormalPoly);
|
||||
private static readonly byte[] BitReversedBytes = new byte[256];
|
||||
|
||||
private readonly uint[] crc32Table;
|
||||
@@ -20,7 +21,6 @@
|
||||
|
||||
static Crc32()
|
||||
{
|
||||
InitCrc32Table();
|
||||
InitReversedBitOrderTable();
|
||||
}
|
||||
|
||||
@@ -42,11 +42,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static uint[] InitCrc32Table()
|
||||
/// <param name="msbFirst">true for using the "left shift" most-significant-bit-first algorithm</param>
|
||||
/// <param name="poly"></param>
|
||||
public Crc32(bool msbFirst, uint poly)
|
||||
{
|
||||
this.msbFirst = msbFirst;
|
||||
this.crc32Table = InitCrc32Table(poly);
|
||||
}
|
||||
|
||||
#region InitCrc32Table()
|
||||
private uint[] InitCrc32Table(uint poly)
|
||||
{
|
||||
var crcTable = new uint[256];
|
||||
var poly = CrcPoly;
|
||||
for (uint i = 0; i < 256; i++)
|
||||
{
|
||||
uint r = i << 24;
|
||||
@@ -65,13 +74,6 @@
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <param name="msbFirst">true for using the "left shift" MSB-first algorithm with polynomial 0x04C11Db7. false to use "right shift" with polynomial 0xEDB883320</param>
|
||||
public Crc32(bool msbFirst = true)
|
||||
{
|
||||
this.msbFirst = msbFirst;
|
||||
crc32Table = InitCrc32Table();
|
||||
}
|
||||
|
||||
#region CalcCrc32()
|
||||
public uint CalcCrc32(byte[] data, int start, int length)
|
||||
{
|
||||
|
||||
@@ -37,6 +37,30 @@ namespace ChanSort.Api
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetMask()
|
||||
public int GetMask(string key)
|
||||
{
|
||||
var list = settings.GetIntList(key);
|
||||
if (list != null && list.Length > 0)
|
||||
return list[0];
|
||||
list = settings.GetIntList("mask" + key);
|
||||
if (list != null && list.Length > 0)
|
||||
return list[0];
|
||||
return -1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetConst()
|
||||
public int GetConst(string key, int defaultValue)
|
||||
{
|
||||
var list = settings.GetIntList(key);
|
||||
if (list != null && list.Length > 0)
|
||||
return list[0];
|
||||
return defaultValue;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public IniFile.Section Settings { get { return this.settings; } }
|
||||
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ namespace ChanSort.Api
|
||||
|
||||
#region GetInt16/32()
|
||||
|
||||
public static int GetInt16(byte[] data, int offset, bool littleEndian)
|
||||
public static int GetInt16(this byte[] data, int offset, bool littleEndian = true)
|
||||
{
|
||||
return littleEndian ? BitConverter.ToInt16(data, offset) : (data[offset] << 8) + data[offset + 1];
|
||||
}
|
||||
|
||||
public static int GetInt32(byte[] data, int offset, bool littleEndian)
|
||||
public static int GetInt32(this byte[] data, int offset, bool littleEndian = true)
|
||||
{
|
||||
return littleEndian ? BitConverter.ToInt32(data, offset) :
|
||||
(data[offset] << 24) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3];
|
||||
@@ -45,7 +45,7 @@ namespace ChanSort.Api
|
||||
|
||||
#region SetInt16/32()
|
||||
|
||||
public static void SetInt16(byte[] data, int offset, int value, bool littleEndian = true)
|
||||
public static void SetInt16(this byte[] data, int offset, int value, bool littleEndian = true)
|
||||
{
|
||||
if (littleEndian)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ namespace ChanSort.Api
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetInt32(byte[] data, int offset, int value, bool littleEndian = true)
|
||||
public static void SetInt32(this byte[] data, int offset, int value, bool littleEndian = true)
|
||||
{
|
||||
if (littleEndian)
|
||||
{
|
||||
@@ -82,11 +82,10 @@ namespace ChanSort.Api
|
||||
|
||||
public static void MemCopy(byte[] source, int sourceIndex, byte[] dest, int destIndex, int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
dest[destIndex + i] = source[sourceIndex + i];
|
||||
Array.Copy(source, sourceIndex, dest, destIndex, count);
|
||||
}
|
||||
|
||||
public static void MemSet(byte[] data, int offset, byte value, int count)
|
||||
public static void MemSet(this byte[] data, int offset, byte value, int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
data[offset++] = value;
|
||||
|
||||
Reference in New Issue
Block a user