mpc: Move to a module and split thirdparty libmpcdec

This commit is contained in:
Rémi Verschelde 2016-10-13 20:46:42 +02:00
parent cfcc8a20e8
commit 5c12c9e69b
34 changed files with 158 additions and 55 deletions

View file

@ -131,7 +131,7 @@ opts.Add('libpng','libpng library for image loader support (system/builtin)','bu
opts.Add('libwebp','libwebp library for webp module (system/builtin)','builtin')
opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes')
opts.Add('openssl','OpenSSL library for openssl module (system/builtin)','builtin')
opts.Add('musepack','Musepack Audio (yes/no)','yes')
opts.Add('libmpcdec','libmpcdec library for mpc module (system/builtin)','builtin')
opts.Add('enet','ENet library (system/builtin)','builtin')
opts.Add("CXX", "C++ Compiler")
opts.Add("CC", "C Compiler")
@ -318,9 +318,6 @@ if selected_platform in platform_list:
if (env.use_ptrcall):
env.Append(CPPFLAGS=['-DPTRCALL_ENABLED']);
if (env['musepack']=='yes'):
env.Append(CPPFLAGS=['-DMUSEPACK_ENABLED']);
if (env["builtin_zlib"]=='yes'):
env.Append(CPPPATH=['#drivers/builtin_zlib/zlib'])

2
drivers/SCsub vendored
View file

@ -24,8 +24,6 @@ SConscript("chibi/SCsub");
if (env["tools"]=="yes"):
SConscript("convex_decomp/SCsub");
if (env['musepack']=='yes'):
SConscript("mpc/SCsub");
if (env["squish"]=="yes" and env["tools"]=="yes"):
SConscript("squish/SCsub");
if (env["freetype"]!="no"):

View file

@ -1,21 +0,0 @@
Import('env')
mpc_sources = [
"mpc/huffman.c",
"mpc/mpc_bits_reader.c",
"mpc/mpc_decoder.c",
"mpc/mpc_demux.c",
"mpc/mpc_reader.c",
"mpc/requant.c",
"mpc/streaminfo.c",
"mpc/synth_filter.c",
]
env.drivers_sources+=mpc_sources
env.add_source_files(env.drivers_sources,"*.cpp")
#env.add_source_files(env.drivers_sources, mpc_sources)
Export('env')

View file

@ -48,17 +48,9 @@
#include "drivers/nrex/regex.h"
#ifdef MUSEPACK_ENABLED
#include "mpc/audio_stream_mpc.h"
#endif
static ImageLoaderPNG *image_loader_png=NULL;
static ResourceSaverPNG *resource_saver_png=NULL;
#ifdef MUSEPACK_ENABLED
static ResourceFormatLoaderAudioStreamMPC * mpc_stream_loader=NULL;
#endif
void register_core_driver_types() {
@ -87,14 +79,6 @@ void register_driver_types() {
Geometry::_decompose_func=b2d_decompose;
#endif
#ifdef MUSEPACK_ENABLED
mpc_stream_loader=memnew( ResourceFormatLoaderAudioStreamMPC );
ResourceLoader::add_resource_format_loader(mpc_stream_loader);
ObjectTypeDB::register_type<AudioStreamMPC>();
#endif
#ifdef TOOLS_ENABLED
#ifdef SQUISH_ENABLED
@ -108,10 +92,5 @@ void register_driver_types() {
void unregister_driver_types() {
#ifdef MUSEPACK_ENABLED
memdelete (mpc_stream_loader);
#endif
finalize_chibi();
}

26
modules/mpc/SCsub Normal file
View file

@ -0,0 +1,26 @@
Import('env')
Import('env_modules')
env_mpc = env_modules.Clone()
# Thirdparty source files
if (env["libmpcdec"] != "system"): # builtin
thirdparty_dir = "#thirdparty/libmpcdec/"
thirdparty_sources = [
"huffman.c",
"mpc_bits_reader.c",
"mpc_decoder.c",
"mpc_demux.c",
"mpc_reader.c",
"requant.c",
"streaminfo.c",
"synth_filter.c",
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
env_mpc.add_source_files(env.modules_sources, thirdparty_sources)
env_mpc.Append(CPPPATH = [thirdparty_dir])
# Godot source files
env_mpc.add_source_files(env.modules_sources, "*.cpp")

View file

@ -29,13 +29,12 @@
#ifndef AUDIO_STREAM_MPC_H
#define AUDIO_STREAM_MPC_H
#include "scene/resources/audio_stream.h"
#include "os/file_access.h"
#include "mpc/mpcdec.h"
#include "os/thread_safe.h"
#include "io/resource_loader.h"
//#include "../libmpcdec/decoder.h"
//#include "../libmpcdec/internal.h"
#include "os/file_access.h"
#include "os/thread_safe.h"
#include "scene/resources/audio_stream.h"
#include <mpc/mpcdec.h>
class AudioStreamPlaybackMPC : public AudioStreamPlayback {

6
modules/mpc/config.py Normal file
View file

@ -0,0 +1,6 @@
def can_build(platform):
return True
def configure(env):
pass

View file

@ -0,0 +1,45 @@
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
#include "audio_stream_mpc.h"
static ResourceFormatLoaderAudioStreamMPC* mpc_stream_loader = NULL;
void register_mpc_types() {
mpc_stream_loader=memnew( ResourceFormatLoaderAudioStreamMPC );
ResourceLoader::add_resource_format_loader(mpc_stream_loader);
ObjectTypeDB::register_type<AudioStreamMPC>();
}
void unregister_mpc_types() {
memdelete( mpc_stream_loader );
}

View file

@ -0,0 +1,30 @@
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
void register_mpc_types();
void unregister_mpc_types();

View file

@ -26,9 +26,9 @@ def get_flags():
return [
('tools', 'no'),
('musepack', 'no'),
('squish', 'no'),
('etc1', 'no'),
('module_mpc_enabled', 'no'),
('module_theora_enabled', 'no'),
]

13
thirdparty/README.md vendored
View file

@ -29,6 +29,19 @@ Files extracted from upstream source:
- jpgd.{c,h}
## libmpcdec
- Upstream: https://www.musepack.net
- Version: SVN somewhere between SV7 and SV8 (r475)
- License: BSD-3-Clause
Files extracted from upstream source:
- all .c and .h files in libmpcdec/
- include/mpc as mpc/
- COPYING from libmpcdec/
## libogg
- Upstream: https://www.xiph.org/ogg

31
thirdparty/libmpcdec/COPYING vendored Normal file
View file

@ -0,0 +1,31 @@
Copyright (c) 2005, The Musepack Development Team
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the The Musepack Development Team nor the
names of its contributors may be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.