Skip to content

Commit

Permalink
Replace FFmpeg with libmpcdec
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-ushakov committed Feb 18, 2024
1 parent 29eaf68 commit a656d78
Show file tree
Hide file tree
Showing 42 changed files with 6,070 additions and 543 deletions.
39 changes: 1 addition & 38 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
submodules: 'recursive'

- name: Install deps
run: sudo apt-get install libx11-dev libxcursor-dev libxi-dev libgl-dev libz-dev nasm
run: sudo apt-get install libx11-dev libxcursor-dev libxi-dev libgl-dev libz-dev

- name: SDL -- cache
id: cache-sdl
Expand All @@ -43,43 +43,6 @@ jobs:
cp -r target-debug/lib ${{github.workspace}}/3rdparty/SDL-2.26.5/
working-directory: SDL

- name: ffmpeg -- cache
id: cache-ffmpeg
uses: actions/cache@v3
with:
path: ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6
key: ${{ runner.os }}-ffmpeg-n4.3.6
- name: ffmpeg -- download
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch n4.3.6 https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
git apply ${{github.workspace}}/avcodec-x86-mathops.patch
- name: ffmpeg -- configure
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: ./configure
--prefix=build
--disable-programs
--disable-doc
--disable-avdevice
--disable-avfilter
--disable-network
--disable-pixelutils
--disable-everything
--enable-decoder=pcm_s16le,mpc7
--enable-demuxer=wav,mpc
--enable-protocol=file
working-directory: ffmpeg
- name: ffmpeg -- build and install
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
make
make install
mkdir -p ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6
cp -r build/include ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6/
cp -r build/lib ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6/
working-directory: ffmpeg

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

Expand Down
34 changes: 1 addition & 33 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ jobs:
submodules: 'recursive'

- name: Install dependencies
run: brew install cmake nasm ninja zlib
run: brew install cmake ninja zlib

- uses: actions/cache@v3
id: cache
with:
path: |
${{github.workspace}}/3rdparty/SDL-2.26.5
${{github.workspace}}/3rdparty/FFmpeg-n4.3.6
key: ${{runner.os}}-${{env.GH_CACHE_KEY}}

- name: SDL -- download
Expand All @@ -46,37 +45,6 @@ jobs:
cp -r target-release/lib ${{github.workspace}}/3rdparty/SDL-2.26.5/
working-directory: SDL

- name: ffmpeg -- download
if: steps.cache.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch n4.3.6 https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
git apply ${{github.workspace}}/avcodec-x86-mathops.patch
- name: ffmpeg -- configure
if: steps.cache.outputs.cache-hit != 'true'
run: ./configure
--prefix=build
--disable-programs
--disable-doc
--disable-avdevice
--disable-avfilter
--disable-network
--disable-pixelutils
--disable-everything
--enable-decoder=pcm_s16le,mpc7
--enable-demuxer=wav,mpc
--enable-protocol=file
working-directory: ffmpeg
- name: ffmpeg -- build and install
if: steps.cache.outputs.cache-hit != 'true'
run: |
make -j4
make install
mkdir -p ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6
cp -r build/include ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6/
cp -r build/lib ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6/
working-directory: ffmpeg

- name: Game -- configure
run: cmake -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Game -- build
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
git
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-nasm
unzip
- name: SDL -- cache
Expand All @@ -49,43 +48,6 @@ jobs:
cp -r target-debug/lib ${{github.workspace}}/3rdparty/SDL-2.26.5/
working-directory: SDL

- name: ffmpeg -- cache
id: cache-ffmpeg
uses: actions/cache@v3
with:
path: ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6
key: ${{ runner.os }}-ffmpeg-n4.3.6
- name: ffmpeg -- download
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch n4.3.6 https://git.ffmpeg.org/ffmpeg.git ffmpeg
cd ffmpeg
git apply ${{github.workspace}}/avcodec-x86-mathops.patch
- name: ffmpeg -- configure
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: msys2 -c './configure
--prefix=build
--disable-programs
--disable-doc
--disable-avdevice
--disable-avfilter
--disable-network
--disable-pixelutils
--disable-everything
--enable-decoder=pcm_s16le,mpc7
--enable-demuxer=wav,mpc
--enable-protocol=file'
working-directory: ffmpeg
- name: ffmpeg -- build and install
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: |
msys2 -c 'mingw32-make -j4'
msys2 -c 'mingw32-make install'
mkdir -p ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6
cp -r build/include ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6/
cp -r build/lib ${{github.workspace}}/3rdparty/FFmpeg-n4.3.6/
working-directory: ffmpeg

- shell: msys2 {0}
run: |
mkdir build-mingw
Expand Down
27 changes: 27 additions & 0 deletions 3rdparty/musepack_src_r475/CMakeLists.txt
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)
56 changes: 56 additions & 0 deletions 3rdparty/musepack_src_r475/common/crc32.c
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;
}
77 changes: 77 additions & 0 deletions 3rdparty/musepack_src_r475/common/fastmath.c
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
Loading

0 comments on commit a656d78

Please sign in to comment.