-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29eaf68
commit a656d78
Showing
42 changed files
with
6,070 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.20) | ||
|
||
project(libmpcdec C) | ||
|
||
include(TestBigEndian) | ||
TEST_BIG_ENDIAN(MPC_ENDIANNESS) | ||
|
||
add_definitions(-DFAST_MATH -DCVD_FASTLOG) | ||
|
||
if(NOT MSVC) | ||
set(CMAKE_C_FLAGS "-O3 -Wall -fomit-frame-pointer -pipe") | ||
endif(NOT MSVC) | ||
|
||
set(SOURCES | ||
common/crc32.c | ||
libmpcdec/huffman.c | ||
libmpcdec/mpc_bits_reader.c | ||
libmpcdec/mpc_decoder.c | ||
libmpcdec/mpc_demux.c | ||
libmpcdec/mpc_reader.c | ||
libmpcdec/requant.c | ||
libmpcdec/streaminfo.c | ||
libmpcdec/synth_filter.c | ||
) | ||
|
||
add_library(mpcdec STATIC ${SOURCES}) | ||
target_include_directories(mpcdec PUBLIC include) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* C Implementation: crc32 | ||
* | ||
* code from http://www.w3.org/TR/PNG/#D-CRCAppendix | ||
* | ||
*/ | ||
|
||
/* Table of CRCs of all 8-bit messages. */ | ||
static unsigned long crc_table[256]; | ||
|
||
/* Flag: has the table been computed? Initially false. */ | ||
static int crc_table_computed = 0; | ||
|
||
/* Make the table for a fast CRC. */ | ||
static void make_crc_table(void) | ||
{ | ||
unsigned long c; | ||
int n, k; | ||
|
||
for (n = 0; n < 256; n++) { | ||
c = (unsigned long) n; | ||
for (k = 0; k < 8; k++) { | ||
if (c & 1) | ||
c = 0xedb88320L ^ (c >> 1); | ||
else | ||
c = c >> 1; | ||
} | ||
crc_table[n] = c; | ||
} | ||
crc_table_computed = 1; | ||
} | ||
|
||
|
||
/* Update a running CRC with the bytes buf[0..len-1]--the CRC | ||
should be initialized to all 1's, and the transmitted value | ||
is the 1's complement of the final running CRC (see the | ||
crc() routine below). */ | ||
|
||
static unsigned long update_crc(unsigned long crc, unsigned char *buf, int len) | ||
{ | ||
unsigned long c = crc; | ||
int n; | ||
|
||
if (!crc_table_computed) | ||
make_crc_table(); | ||
for (n = 0; n < len; n++) { | ||
c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8); | ||
} | ||
return c; | ||
} | ||
|
||
/* Return the CRC of the bytes buf[0..len-1]. */ | ||
unsigned long mpc_crc32(unsigned char *buf, int len) | ||
{ | ||
return update_crc(0xffffffffL, buf, len) ^ 0xffffffffL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Musepack audio compression | ||
* Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
#include "mpc/mpcmath.h" | ||
|
||
#ifdef FAST_MATH | ||
|
||
const float tabatan2 [ 2*TABSTEP+1] [2]; | ||
const float tabcos [26*TABSTEP+1] [2]; | ||
const float tabsqrt_ex [256]; | ||
const float tabsqrt_m [ TABSTEP+1] [2]; | ||
|
||
|
||
void Init_FastMath ( void ) | ||
{ | ||
int i; mpc_floatint X, Y; double xm, x0, xp, x, y; float* p; | ||
|
||
p = (float*) tabatan2; | ||
for ( i = -TABSTEP; i <= TABSTEP; i++ ) { | ||
xm = atan ((i-0.5)/TABSTEP); | ||
x0 = atan ((i+0.0)/TABSTEP); | ||
xp = atan ((i+0.5)/TABSTEP); | ||
x = x0/2 + (xm + xp)/4; | ||
y = xp - xm; | ||
*p++ = x; | ||
*p++ = y; | ||
} | ||
|
||
p = (float*) tabcos; | ||
for ( i = -13*TABSTEP; i <= 13*TABSTEP; i++ ) { | ||
xm = cos ((i-0.5)/TABSTEP); | ||
x0 = cos ((i+0.0)/TABSTEP); | ||
xp = cos ((i+0.5)/TABSTEP); | ||
x = x0/2 + (xm + xp)/4; | ||
y = xp - xm; | ||
*p++ = x; | ||
*p++ = y; | ||
} | ||
|
||
p = (float*) tabsqrt_ex; | ||
for ( i = 0; i < 255; i++ ) { | ||
X.n = (i << 23); | ||
Y.n = (i << 23) + (1<<23) - 1; | ||
*p++ = sqrt(X.f); | ||
} | ||
X.n = (255 << 23) - 1; | ||
*p++ = sqrt(X.f); | ||
|
||
p = (float*) tabsqrt_m; | ||
for ( i = 1*TABSTEP; i <= 2*TABSTEP; i++ ) { | ||
xm = sqrt ((i-0.5)/TABSTEP); | ||
x0 = sqrt ((i+0.0)/TABSTEP); | ||
xp = sqrt ((i+0.5)/TABSTEP); | ||
x = x0/2 + (xm + xp)/4; | ||
y = xp - xm; | ||
*p++ = x; | ||
*p++ = y; | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.