Skip to content

Commit

Permalink
Initial upload to GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
soiaf committed Feb 22, 2016
1 parent 980cf61 commit 0eca94b
Show file tree
Hide file tree
Showing 30 changed files with 4,824 additions and 0 deletions.
62 changes: 62 additions & 0 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System.Reflection;
using System.Runtime.CompilerServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

// TODO: Review the values of the assembly attributes

[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]


// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Revision
// Build Number
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.0.*")]

//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\..\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]


158 changes: 158 additions & 0 deletions BitsUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
using System;
/*
** BitsUtils.cs
**
** Copyright (c) 2010-2016 Peter McQuillan
**
** All Rights Reserved.
**
** Distributed under the BSD Software License (see license.txt)
***/

class BitsUtils
{
internal static Bitstream getbit(Bitstream bs)
{
if (bs.bc > 0)
{
bs.bc--;
}
else
{
bs.ptr++;
bs.buf_index++;
bs.bc = 7;

if (bs.ptr == bs.end)
{
// wrap call here
bs = bs_read(bs);
}
bs.sr = (bs.buf[bs.buf_index] & 0xff);
}

bs.bitval = (int)(bs.sr & 1);
bs.sr = bs.sr >> 1;
return bs;
}

internal static long getbits(int nbits, Bitstream bs)
{
int uns_buf;
long retval;

while ((nbits) > bs.bc)
{
bs.ptr++;
bs.buf_index++;

if (bs.ptr == bs.end)
{
bs = bs_read(bs);
}
uns_buf = (int) (bs.buf[bs.buf_index] & 0xff);
bs.sr = bs.sr | (uns_buf << bs.bc); // values in buffer must be unsigned

bs.sr = bs.sr & 0xFFFFFFFFL; // sr is an unsigned 32 bit variable

bs.bc += 8;
}

retval = bs.sr;

if (bs.bc > 32)
{
bs.bc -= (nbits);
bs.sr = (bs.buf[bs.buf_index] & 0xff) >> (8 - bs.bc);
}
else
{
bs.bc -= (nbits);
bs.sr >>= (nbits);
}

return (retval);
}

internal static Bitstream bs_open_read(byte[] stream, short buffer_start, short buffer_end, System.IO.BinaryReader file, int file_bytes, int passed)
{
// CLEAR (*bs);
Bitstream bs = new Bitstream();

bs.buf = stream;
bs.buf_index = buffer_start;
bs.end = buffer_end;
bs.sr = 0;
bs.bc = 0;

if (passed != 0)
{
bs.ptr = (short) (bs.end - 1);
bs.file_bytes = file_bytes;
bs.file = file;
}
else
{
/* Strange to set an index to -1, but the very first call to getbit will iterate this */
bs.buf_index = - 1;
bs.ptr = (short) (- 1);
}

return bs;
}

internal static Bitstream bs_read(Bitstream bs)
{
if (bs.file_bytes > 0)
{
int bytes_to_read;
int bytes_read;

bytes_to_read = Defines.BITSTREAM_BUFFER_SIZE;

if (bytes_to_read > bs.file_bytes)
bytes_to_read = bs.file_bytes;

try
{
bytes_read = bs.file.BaseStream.Read(bs.buf, 0, bytes_to_read);

bs.buf_index = 0;
}
catch (System.Exception e)
{
System.Console.Error.WriteLine("Big error while reading file: " + e);
bytes_read = 0;
}

if (bytes_read > 0)
{
bs.end = (short) (bytes_read);
bs.file_bytes -= bytes_read;
}
else
{
for (int i = 0; i < Defines.BITSTREAM_BUFFER_SIZE; i++)
{
bs.buf[i] = unchecked((byte)-1);
}
bs.error = 1;
}
}
else
{
bs.error = 1;

for (int i = 0; i < Defines.BITSTREAM_BUFFER_SIZE; i++)
{
bs.buf[i] = unchecked((byte)-1);
}
}


bs.ptr = 0;
bs.buf_index = 0;

return bs;
}
}
22 changes: 22 additions & 0 deletions Bitstream.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
/*
** Bitstream.cs
**
** Copyright (c) 2010-2016 Peter McQuillan
**
** All Rights Reserved.
**
** Distributed under the BSD Software License (see license.txt)
***/

class Bitstream
{
internal short end, ptr; // was uchar in c
internal long sr;
internal int file_bytes;
internal int error, bc;
internal System.IO.BinaryReader file;
internal int bitval = 0;
internal byte[] buf = new byte[Defines.BITSTREAM_BUFFER_SIZE];
internal int buf_index = 0;
}
18 changes: 18 additions & 0 deletions CSharpWavPackDecoder.application
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity name="CSharpWavPackDecoder.application" version="1.1.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="CSharpWavPackDecoder" asmv2:product="CSharpWavPackDecoder" xmlns="urn:schemas-microsoft-com:asm.v1" />
<deployment install="true" mapFileExtensions="true" />
<dependency>
<dependentAssembly dependencyType="install" codebase="CSharpWavPackDecoder.exe.manifest" size="6087">
<assemblyIdentity name="CSharpWavPackDecoder.exe" version="1.1.0.1" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="msil" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>cB9XwrUuuay8pS5bD6VZeprNw3I=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
</asmv1:assembly>
Loading

0 comments on commit 0eca94b

Please sign in to comment.