Merge pull request #1 from kode54/master

Seeing if I can merge the master branch into mine
This commit is contained in:
Joseph Gibbs 2015-05-11 17:57:11 -04:00
commit 3a8fd1eecc
32 changed files with 507 additions and 350 deletions

23
ext_includes/g719.h Executable file
View File

@ -0,0 +1,23 @@
/*
Interface to reference G.719 decoder
*/
#ifndef G719_H
#define G719_H
/* forward definition for the opaque handle object */
typedef struct g719_handle_s g719_handle;
/* return a handle for decoding on successful init, NULL on failure */
g719_handle * g719_init(int sample_rate);
/* decode a frame, at code_words, into 16-bit PCM in sample_buffer */
void g719_decode_frame(g719_handle *handle, void *code_words, void *sample_buffer);
/* reset the decoder to its initial state */
void g719_reset(g719_handle *handle);
/* free resources */
void g719_free(g719_handle *handle);
#endif

View File

@ -11,6 +11,9 @@ libmpg123-0.a: libmpg123-0.def
libg7221_decode.a: libg7221_decode.def
$(DLLTOOL) -d libg7221_decode.def -l libg7221_decode.a
libg719_decode.a: libg719_decode.def
$(DLLTOOL) -d libg719_decode.def -l libg719_decode.a
at3plusdecoder.a: at3plusdecoder.def
$(DLLTOOL) -d at3plusdecoder.def -l at3plusdecoder.a

View File

@ -131,6 +131,30 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\libg719_decode.def"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Building library stub"
CommandLine="lib /def:libg719_decode.def /machine:x86&#x0D;&#x0A;"
Outputs="libg719_decode.lib libg719_decode.exp"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Building library stub"
CommandLine="lib /def:libg719_decode.def /machine:x86&#x0D;&#x0A;"
Outputs="libg719_decode.lib libg719_decode.exp"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -88,6 +88,16 @@
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">libg7221_decode.lib;libg7221_decode.exp;%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="libg719_decode.def">
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Building library stub</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">lib /def:libg719_decode.def /machine:x86
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">libg719_decode.lib;libg719_decode.exp;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Building library stub</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">lib /def:libg719_decode.def /machine:x86
</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">libg719_decode.lib;libg719_decode.exp;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

6
ext_libs/libg719_decode.def Executable file
View File

@ -0,0 +1,6 @@
LIBRARY libg719_decode.dll
EXPORTS
g719_decode_frame @1
g719_free @2
g719_init @3
g719_reset @4

BIN
ext_libs/libg719_decode.dll Executable file

Binary file not shown.

View File

@ -78,7 +78,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>../ext_libs/libvorbis.lib;../ext_libs/libmpg123-0.lib;../ext_libs/libg7221_decode.lib;../ext_libs/at3plusdecoder.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>../ext_libs/libvorbis.lib;../ext_libs/libmpg123-0.lib;../ext_libs/libg7221_decode.lib;../ext_libs/libg719_decode.lib;../ext_libs/at3plusdecoder.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -103,7 +103,7 @@
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
</ClCompile>
<Link>
<AdditionalDependencies>../ext_libs/libvorbis.lib;../ext_libs/libmpg123-0.lib;../ext_libs/libg7221_decode.lib;../ext_libs/at3plusdecoder.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>../ext_libs/libvorbis.lib;../ext_libs/libmpg123-0.lib;../ext_libs/libg7221_decode.lib;../ext_libs/libg719_decode.lib;../ext_libs/at3plusdecoder.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>

View File

@ -62,7 +62,7 @@ class input_vgmstream {
short sample_buffer[OUTBUF_SIZE];
void getfileinfo(const char *filename, char *title, int *length_in_ms, int *total_samples, int *loop_start, int *loop_end, int *sample_rate, int *channels, abort_callback & p_abort);
void getfileinfo(const char *filename, char *title, int *length_in_ms, int *total_samples, int *loop_start, int *loop_end, int *sample_rate, int *channels, int *bitrate, abort_callback & p_abort);
void load_settings();
private:

View File

@ -115,15 +115,16 @@ void input_vgmstream::open(service_ptr_t<file> p_filehint,const char * p_path,t_
void input_vgmstream::get_info(file_info & p_info,abort_callback & p_abort ) {
int length_in_ms=0, channels = 0, samplerate = 0;
int total_samples = -1;
int bitrate = 0;
int loop_start = -1, loop_end = -1;
getfileinfo(filename, NULL, &length_in_ms, &total_samples, &loop_start, &loop_end, &samplerate, &channels, p_abort);
getfileinfo(filename, NULL, &length_in_ms, &total_samples, &loop_start, &loop_end, &samplerate, &channels, &bitrate, p_abort);
p_info.info_set_int("samplerate", samplerate);
p_info.info_set_int("channels", channels);
p_info.info_set_int("bitspersample",16);
p_info.info_set("encoding","lossless");
p_info.info_set_bitrate((samplerate * 16 * channels) / 1000);
p_info.info_set_bitrate(bitrate / 1000);
if (total_samples > 0)
p_info.info_set_int("stream_total_samples", total_samples);
if (loop_start >= 0 && loop_end >= loop_start)
@ -555,7 +556,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension
/* retrieve information on this or possibly another file */
void input_vgmstream::getfileinfo(const char *filename, char *title, int *length_in_ms, int *total_samples, int *loop_start, int *loop_end, int *sample_rate, int *channels, abort_callback & p_abort) {
void input_vgmstream::getfileinfo(const char *filename, char *title, int *length_in_ms, int *total_samples, int *loop_start, int *loop_end, int *sample_rate, int *channels, int *bitrate, abort_callback & p_abort) {
VGMSTREAM * infostream;
if (length_in_ms)
@ -568,6 +569,7 @@ void input_vgmstream::getfileinfo(const char *filename, char *title, int *length
*sample_rate = infostream->sample_rate;
*channels = infostream->channels;
*total_samples = infostream->num_samples;
*bitrate = get_vgmstream_average_bitrate(infostream);
if (infostream->loop_flag)
{
*loop_start = infostream->loop_start_sample;

View File

@ -22,7 +22,8 @@ CODING_OBJS=coding/adx_decoder.o \
coding/g7221_decoder.o \
coding/lsf_decoder.o \
coding/mtaf_decoder.o \
coding/at3_decoder.o
coding/at3_decoder.o \
coding/g719_decoder.o
LAYOUT_OBJS=layout/ast_blocked.o \
layout/blocked.o \

View File

@ -29,5 +29,6 @@ libcoding_la_SOURCES += SASSC_decoder.c
libcoding_la_SOURCES += g7221_decoder.c
libcoding_la_SOURCES += lsf_decoder.c
libcoding_la_SOURCES += mtaf_decoder.c
libcoding_la_SOURCES += g719_decoder.c
EXTRA_DIST = coding.h g72x_state.h

View File

@ -98,6 +98,11 @@ void decode_g7221(VGMSTREAM *vgmstream,
sample * outbuf, int channelspacing, int32_t samples_to_do, int channel);
#endif
#ifdef VGM_USE_G719
void decode_g719(VGMSTREAM *vgmstream,
sample * outbuf, int channelspacing, int32_t samples_to_do, int channel);
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
void decode_at3plus(VGMSTREAM *vgmstream,
sample * outbuf, int channelspacing, int32_t samples_to_do, int channel);

29
src/coding/g719_decoder.c Normal file
View File

@ -0,0 +1,29 @@
#include "../vgmstream.h"
#ifdef VGM_USE_G719
#include "coding.h"
#include "../util.h"
#include "../stack_alloc.h"
void decode_g719(VGMSTREAM * vgmstream,
sample * outbuf, int channelspacing, int32_t samples_to_do, int channel) {
VGMSTREAMCHANNEL *ch = &vgmstream->ch[channel];
g719_codec_data *data = vgmstream->codec_data;
g719_codec_data *ch_data = &data[channel];
int i;
if (0 == vgmstream->samples_into_block)
{
VARDECL(int16_t,code_buffer);
ALLOC(code_buffer, vgmstream->interleave_block_size / 2, int16_t);
vgmstream->ch[channel].streamfile->read(ch->streamfile, (uint8_t*)code_buffer, ch->offset, vgmstream->interleave_block_size);
g719_decode_frame(ch_data->handle, code_buffer, ch_data->buffer);
}
for (i = 0; i < samples_to_do; i++)
{
outbuf[i*channelspacing] = ch_data->buffer[vgmstream->samples_into_block+i];
}
}
#endif

View File

@ -1,7 +1,6 @@
#include "../vgmstream.h"
#ifdef VGM_USE_G7221
#include "g7221.h"
#include "coding.h"
#include "../util.h"

View File

@ -41,7 +41,7 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../ext_includes"
PreprocessorDefinitions="WIN32;VGM_USE_G7221;_DEBUG;_LIB;"
PreprocessorDefinitions="WIN32;VGM_USE_G7221;VGM_USE_G719;USE_ALLOCA;_DEBUG;_LIB;"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
@ -103,7 +103,7 @@
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../ext_includes"
PreprocessorDefinitions="WIN32;VGM_USE_G7221;NDEBUG;_LIB;"
PreprocessorDefinitions="WIN32;VGM_USE_G7221;VGM_USE_G719;USE_ALLOCA;NDEBUG;_LIB;"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -272,6 +272,10 @@
RelativePath=".\meta\brstm.c"
>
</File>
<File
RelativePath=".\meta\btsnd.c"
>
</File>
<File
RelativePath=".\meta\capdsp.c"
>
@ -416,6 +420,10 @@
RelativePath=".\meta\maxis_xa.c"
>
</File>
<File
RelativePath=".\meta\mca.c"
>
</File>
<File
RelativePath=".\meta\mn_str.c"
>
@ -1210,6 +1218,10 @@
RelativePath=".\coding\eaxa_decoder.c"
>
</File>
<File
RelativePath=".\coding\g719_decoder.c"
>
</File>
<File
RelativePath=".\coding\g721_decoder.c"
>

View File

@ -56,7 +56,7 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@ -70,7 +70,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
@ -154,6 +154,7 @@
<ClCompile Include="meta\bgw.c" />
<ClCompile Include="meta\bnsf.c" />
<ClCompile Include="meta\brstm.c" />
<ClCompile Include="meta\btsnd.c" />
<ClCompile Include="meta\capdsp.c" />
<ClCompile Include="meta\Cstr.c" />
<ClCompile Include="meta\dc_asd.c" />
@ -185,6 +186,7 @@
<ClCompile Include="meta\ivb.c" />
<ClCompile Include="meta\kraw.c" />
<ClCompile Include="meta\maxis_xa.c" />
<ClCompile Include="meta\mca.c" />
<ClCompile Include="meta\msvp.c" />
<ClCompile Include="meta\mus_acm.c">
<ObjectFileName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(IntDir)%(Filename)1.obj</ObjectFileName>
@ -353,6 +355,7 @@
<ClCompile Include="coding\adx_decoder.c" />
<ClCompile Include="coding\aica_decoder.c" />
<ClCompile Include="coding\eaxa_decoder.c" />
<ClCompile Include="coding\g719_decoder.c" />
<ClCompile Include="coding\g721_decoder.c" />
<ClCompile Include="coding\g7221_decoder.c" />
<ClCompile Include="coding\ima_decoder.c" />

View File

@ -127,6 +127,9 @@
<ClCompile Include="meta\brstm.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\btsnd.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\capdsp.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
@ -220,6 +223,9 @@
<ClCompile Include="meta\maxis_xa.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\mca.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\msvp.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

View File

@ -1,6 +1,6 @@
noinst_LTLIBRARIES = libmeta.la
AM_CFLAGS = -Wall @CFLAGS@ -I$(top_builddir) -I$(top_srcdir)
AM_CFLAGS = -Wall @CFLAGS@ -DVAR_ARRAYS -I$(top_builddir) -I$(top_srcdir)
AM_MAKEFLAGS=-f Makefile.unix
libmeta_la_LDFLAGS =

View File

@ -15,6 +15,7 @@ VGMSTREAM * init_vgmstream_bnsf(STREAMFILE *streamFile) {
uint32_t bnsf_form;
enum {
form_IS14 = UINT32_C(0x49533134), /* IS14 */
form_IS22 = UINT32_C(0x49533232), /* IS22 */
};
int channel_count = 0;
@ -32,6 +33,7 @@ VGMSTREAM * init_vgmstream_bnsf(STREAMFILE *streamFile) {
int FormatChunkFound = 0;
int DataChunkFound = 0;
int RiffSizeExtra = 8;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
@ -51,6 +53,11 @@ VGMSTREAM * init_vgmstream_bnsf(STREAMFILE *streamFile) {
#ifdef VGM_USE_G7221
case form_IS14:
break;
#endif
#ifdef VGM_USE_G719
case form_IS22:
RiffSizeExtra = 0;
break;
#endif
default:
goto fail;
@ -60,7 +67,7 @@ VGMSTREAM * init_vgmstream_bnsf(STREAMFILE *streamFile) {
file_size = get_streamfile_size(streamFile);
/* check for tructated RIFF */
if (file_size < riff_size+8) goto fail;
if (file_size < riff_size+RiffSizeExtra) goto fail;
/* read through chunks to verify format and find metadata */
{
@ -128,6 +135,13 @@ VGMSTREAM * init_vgmstream_bnsf(STREAMFILE *streamFile) {
break;
#endif
#ifdef VGM_USE_G719
case form_IS22:
coding_type = coding_G719;
sample_count = data_size/block_size*block_samples;
break;
#endif
default:
goto fail;
}
@ -178,6 +192,33 @@ VGMSTREAM * init_vgmstream_bnsf(STREAMFILE *streamFile) {
}
#endif
#ifdef VGM_USE_G719
if (coding_G719 == coding_type)
{
int i;
g719_codec_data *data;
/* one data structure per channel */
data = malloc(sizeof(g719_codec_data) * channel_count);
if (!data)
{
goto fail;
}
memset(data,0,sizeof(g719_codec_data) * channel_count);
vgmstream->codec_data = data;
for (i = 0; i < channel_count; i++)
{
/* Siren 22 == 22khz bandwidth */
data[i].handle = g719_init(vgmstream->interleave_block_size);
if (!data[i].handle)
{
goto fail; /* close_vgmstream is able to clean up */
}
}
}
#endif
/* open the file, set up each channel */
{
int i;

View File

@ -12,6 +12,9 @@ VGMSTREAM * init_vgmstream_mca(STREAMFILE *streamFile) {
int channel_count;
int loop_flag;
off_t start_offset;
off_t coef_offset;
int i, j;
int coef_spacing;
/* check extension, case insensitive */
streamFile->get_name(streamFile, filename, sizeof(filename));
@ -58,9 +61,8 @@ VGMSTREAM * init_vgmstream_mca(STREAMFILE *streamFile) {
off_t coef_offset = start_offset - (vgmstream->channels * 0x30);
int i, j;
int coef_spacing = 0x30;
coef_offset = start_offset - (vgmstream->channels * 0x30);
coef_spacing = 0x30;
for (j = 0; j<vgmstream->channels; j++) {
for (i = 0; i<16; i++) {
@ -71,7 +73,6 @@ VGMSTREAM * init_vgmstream_mca(STREAMFILE *streamFile) {
/* open the file for reading by each channel */
{
int i;
for (i = 0; i<channel_count; i++) {
if (vgmstream->layout_type == layout_interleave_shortblock)
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,

View File

@ -2,6 +2,7 @@
#include "../layout/layout.h"
#include "../coding/coding.h"
#include "../util.h"
#include "../stack_alloc.h"
/* If these variables are packed properly in the struct (one after another)
* then this is actually how they are laid out in the file, albeit big-endian */
@ -2375,10 +2376,13 @@ VGMSTREAM * init_vgmstream_dsp_dspw(STREAMFILE *streamFile) {
off_t streamSize, mrkrOffset, channelSpacing;
int channel_count, i, j;
int found_mrkr = 0;
channel_count = read_8bit(0x1B, streamFile);
VARDECL(struct dsp_header, ch_header);
VARDECL(off_t, channel_start);
struct dsp_header ch_header[channel_count];
off_t channel_start[channel_count];
channel_count = (unsigned char)read_8bit(0x1B, streamFile);
ALLOC(ch_header, channel_count, struct dsp_header);
ALLOC(channel_start, channel_count, off_t);
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));

View File

@ -37,6 +37,9 @@ VGMSTREAM * init_vgmstream_ps2_joe(STREAMFILE *streamFile) {
dataLength = read_32bitLE(0x4,streamFile);
dataInterleave = read_32bitLE(0x8,streamFile);
if (!dataInterleave)
dataInterleave = 16; /* XXX */
/* fill in the vital statistics */
start_offset = fileLength - dataLength;
vgmstream->channels = channel_count;

112
src/stack_alloc.h Normal file
View File

@ -0,0 +1,112 @@
/* Copyright (C) 2002-2003 Jean-Marc Valin
Copyright (C) 2007-2009 Xiph.Org Foundation */
/**
@file stack_alloc.h
@brief Temporary memory allocation on stack
*/
/*
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.
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.
*/
#ifndef STACK_ALLOC_H
#define STACK_ALLOC_H
#if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA))
#error "Vgmstream requires one of VAR_ARRAYS or USE_ALLOCA be defined to select the temporary allocation mode."
#endif
#ifdef USE_ALLOCA
# ifdef WIN32
# include <malloc.h>
# else
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# else
# include <stdlib.h>
# endif
# endif
#endif
/**
* @def ALIGN(stack, size)
*
* Aligns the stack to a 'size' boundary
*
* @param stack Stack
* @param size New size boundary
*/
/**
* @def PUSH(stack, size, type)
*
* Allocates 'size' elements of type 'type' on the stack
*
* @param stack Stack
* @param size Number of elements
* @param type Type of element
*/
/**
* @def VARDECL(var)
*
* Declare variable on stack
*
* @param var Variable to declare
*/
/**
* @def ALLOC(var, size, type)
*
* Allocate 'size' elements of 'type' on stack
*
* @param var Name of variable to allocate
* @param size Number of elements
* @param type Type of element
*/
#if defined(VAR_ARRAYS)
#define VARDECL(type, var)
#define ALLOC(var, size, type) type var[size]
#define SAVE_STACK
#define RESTORE_STACK
#define ALLOC_STACK
#elif defined(USE_ALLOCA)
#define VARDECL(type, var) type *var
# ifdef WIN32
# define ALLOC(var, size, type) var = ((type*)_alloca(sizeof(type)*(size)))
# else
# define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size)))
# endif
#define SAVE_STACK
#define RESTORE_STACK
#define ALLOC_STACK
#endif /* VAR_ARRAYS */
#endif /* STACK_ALLOC_H */

View File

@ -465,6 +465,18 @@ void reset_vgmstream(VGMSTREAM * vgmstream) {
}
#endif
#ifdef VGM_USE_G719
if (vgmstream->coding_type==coding_G719) {
g719_codec_data *data = vgmstream->codec_data;
int i;
for (i = 0; i < vgmstream->channels; i++)
{
g719_reset(data[i].handle);
}
}
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
if (vgmstream->coding_type==coding_AT3plus) {
maiatrac3plus_codec_data *data = vgmstream->codec_data;
@ -664,6 +676,25 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
}
#endif
#ifdef VGM_USE_G719
if (vgmstream->coding_type == coding_G719) {
g719_codec_data *data = vgmstream->codec_data;
if (data)
{
int i;
for (i = 0; i < vgmstream->channels; i++)
{
g719_free(data[i].handle);
}
free(data);
}
vgmstream->codec_data = NULL;
}
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
if (vgmstream->coding_type == coding_AT3plus) {
maiatrac3plus_codec_data *data = vgmstream->codec_data;
@ -978,6 +1009,10 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
return 32000/50;
case coding_G7221:
return 16000/50;
#endif
#ifdef VGM_USE_G719
case coding_G719:
return 48000/50;
#endif
case coding_LSF:
return 54;
@ -1086,6 +1121,9 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
case coding_G7221C:
case coding_G7221:
#endif
#ifdef VGM_USE_G719:
case coding_G719:
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
case coding_AT3plus:
#endif
@ -1475,6 +1513,17 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
}
break;
#endif
#ifdef VGM_USE_G719
case coding_G719:
for (chan=0;chan<vgmstream->channels;chan++) {
decode_g719(vgmstream,
buffer+samples_written*vgmstream->channels+chan,
vgmstream->channels,
samples_to_do,
chan);
}
break;
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
case coding_AT3plus:
for (chan=0;chan<vgmstream->channels;chan++) {
@ -1921,6 +1970,11 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
snprintf(temp,TEMPSIZE,"ITU G.722.1 annex C (Polycom Siren 14)");
break;
#endif
#ifdef VGM_USE_G719
case coding_G719:
snprintf(temp,TEMPSIZE,"ITU G.719 annex B (Polycom Siren 22)");
break;
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
case coding_AT3plus:
snprintf(temp,TEMPSIZE,"ATRAC3plus");
@ -3253,3 +3307,108 @@ void try_dual_file_stereo(VGMSTREAM * opened_stream, STREAMFILE *streamFile) {
fail:
return;
}
static int get_vgmstream_channel_count(VGMSTREAM * vgmstream)
{
if (vgmstream->layout_type==layout_scd_int) {
scd_int_codec_data *data = vgmstream->codec_data;
if (data) {
return data->substream_count;
}
else {
return 0;
}
}
#ifdef VGM_USE_VORBIS
if (vgmstream->coding_type==coding_ogg_vorbis) {
ogg_vorbis_codec_data *data = vgmstream->codec_data;
if (data) {
return 1;
}
else {
return 0;
}
}
#endif
#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC)
if (vgmstream->coding_type==coding_MP4_AAC) {
mp4_aac_codec_data *data = vgmstream->codec_data;
if (data) {
return 1;
}
else {
return 0;
}
}
#endif
return vgmstream->channels;
}
static STREAMFILE * get_vgmstream_streamfile(VGMSTREAM * vgmstream, int channel)
{
if (vgmstream->layout_type==layout_scd_int) {
scd_int_codec_data *data = vgmstream->codec_data;
return data->intfiles[channel];
}
#ifdef VGM_USE_VORBIS
if (vgmstream->coding_type==coding_ogg_vorbis) {
ogg_vorbis_codec_data *data = vgmstream->codec_data;
return data->ov_streamfile.streamfile;
}
#endif
#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC)
if (vgmstream->coding_type==coding_MP4_AAC) {
mp4_aac_codec_data *data = vgmstream->codec_data;
return data->if_file.streamfile;
}
#endif
return vgmstream->ch[channel].streamfile;
}
static int get_vgmstream_channel_average_bitrate(STREAMFILE * streamfile, int sample_rate, int length_samples)
{
return (int)((int64_t)get_streamfile_size(streamfile) * 8 * sample_rate / length_samples);
}
int get_vgmstream_average_bitrate(VGMSTREAM * vgmstream)
{
char path_current[PATH_LIMIT];
char path_compare[PATH_LIMIT];
unsigned int i, j;
int bitrate = 0;
int sample_rate = vgmstream->sample_rate;
int length_samples = vgmstream->num_samples;
int channels = get_vgmstream_channel_count(vgmstream);
STREAMFILE * streamFile;
if (channels >= 1) {
streamFile = get_vgmstream_streamfile(vgmstream, 0);
if (streamFile) {
bitrate += get_vgmstream_channel_average_bitrate(streamFile, sample_rate, length_samples);
}
}
for (i = 1; i < channels; ++i)
{
streamFile = get_vgmstream_streamfile(vgmstream, i);
if (!streamFile)
continue;
streamFile->get_name(streamFile, path_current, sizeof(path_current));
for (j = 0; j < i; ++j)
{
STREAMFILE * compareFile = get_vgmstream_streamfile(vgmstream, j);
if (!compareFile)
continue;
streamFile->get_name(compareFile, path_compare, sizeof(path_compare));
if (!strcmp(path_current, path_compare))
break;
}
if (j == i)
bitrate += get_vgmstream_channel_average_bitrate(streamFile, sample_rate, length_samples);
}
return bitrate;
}

View File

@ -16,6 +16,7 @@ enum { PATH_LIMIT = 32768 };
#define VGM_USE_MPEG
/* disabled by default, defined for builds that support it */
//#define VGM_USE_G7221
//#define VGM_USE_G719
#include "streamfile.h"
#include "coding/g72x_state.h"
@ -28,6 +29,9 @@ enum { PATH_LIMIT = 32768 };
#ifdef VGM_USE_G7221
#include "g7221.h"
#endif
#ifdef VGM_USE_G719
#include "g719.h"
#endif
#ifdef VGM_USE_MP4V2
#define MP4V2_NO_STDINT_DEFS
@ -125,6 +129,9 @@ typedef enum {
coding_G7221, /* G.722.1 (Polycom Siren 7) */
coding_G7221C, /* G.722.1 with Annex C extension (Polycom Siren 14) */
#endif
#ifdef VGM_USE_G719
coding_G719,
#endif
coding_ACM, /* InterPlay ACM */
/* compressed NWA at various levels */
@ -740,6 +747,13 @@ typedef struct {
} g7221_codec_data;
#endif
#ifdef VGM_USE_G719
typedef struct {
sample buffer[960];
g719_handle *handle;
} g719_codec_data;
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
typedef struct {
sample *buffer;
@ -875,4 +889,8 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length);
* stereo stream. */
void try_dual_file_stereo(VGMSTREAM * opened_stream, STREAMFILE *streamFile);
/* Return the average bitrate in bps of all unique files contained within this
* stream. Compares files by absolute paths. */
int get_vgmstream_average_bitrate(VGMSTREAM * vgmstream);
#endif

View File

@ -1,6 +1,6 @@
export SHELL = /bin/sh
export CFLAGS=-Wall -O3 -DVGM_USE_G7221 -DVGM_USE_MAIATRAC3PLUS -I../ext_includes
export LDFLAGS=-L../src -L../ext_libs -lvgmstream -lvorbis -lmpg123-0 -lg7221_decode -lat3plusdecoder -lm
export CFLAGS=-Wall -O3 -DVGM_USE_G7221 -DVGM_USE_G719 -DVGM_USE_MAIATRAC3PLUS -DVAR_ARRAYS -I../ext_includes
export LDFLAGS=-L../src -L../ext_libs -lvgmstream -lvorbis -lmpg123-0 -lg7221_decode -lg719_decode -lat3plusdecoder -lm
export CC=i586-mingw32msvc-gcc
export AR=i586-mingw32msvc-ar
export STRIP=i586-mingw32msvc-strip
@ -8,9 +8,9 @@ export STRIP=i586-mingw32msvc-strip
#export AR=i686-w64-mingw32-ar
#export STRIP=i686-w64-mingw32-strip
.PHONY: libvgmstream.a libvorbis.a libmpg123-0.a libg7221_decode.a at3plusdecoder.a
.PHONY: libvgmstream.a libvorbis.a libmpg123-0.a libg7221_decode.a libg719_decode.a at3plusdecoder.a
test.exe: libvgmstream.a libvorbis.a libmpg123-0.a libg7221_decode.a at3plusdecoder.a
test.exe: libvgmstream.a libvorbis.a libmpg123-0.a libg7221_decode.a libg719_decode.a at3plusdecoder.a
$(CC) $(CFLAGS) "-DVERSION=\"`../version.sh`\"" test.c $(LDFLAGS) -o test.exe
$(STRIP) test.exe
@ -26,6 +26,9 @@ libmpg123-0.a:
libg7221_decode.a:
$(MAKE) -C ../ext_libs -f Makefile.mingw $@
libg719_decode.a:
$(MAKE) -C ../ext_libs -f Makefile.mingw $@
at3plusdecoder.a:
$(MAKE) -C ../ext_libs -f Makefile.mingw $@
clean:

View File

@ -1,313 +0,0 @@
#include <audacious/util.h>
void vgmstream_init();
void vgmstream_about();
void vgmstream_configure();
void vgmstream_destroy();
void vgmstream_play(InputPlayback *context);
void vgmstream_stop(InputPlayback *context);
void vgmstream_pause(InputPlayback *context,gshort paused);
void vgmstream_seek(InputPlayback *context,gint time);
int vgmstream_get_time(InputPlayback *context);
void vgmstream_mseek(InputPlayback *context,gulong ms);
void vgmstream_file_info_box(const gchar *pFile);
Tuple * vgmstream_probe_for_tuple(const gchar *uri, VFSFile *fd);
gchar *vgmstream_exts [] = {
"2dx9",
"2pfs",
"aax",
"acm",
"adm",
"adp",
"adpcm",
"ads",
"adx",
"afc",
"agsc",
"ahx",
"aifc",
"aix",
"amts",
"as4",
"asd",
"asf",
"asr",
"ass",
"ast",
"aud",
"aus",
"baka",
"baf",
"bar",
"bcstm",
"bcwav",
"bfstm",
"bfwav",
"bg00",
"bgw",
"bh2pcm",
"bmdx",
"bms",
"bns",
"bnsf",
"bo2",
"brstm",
"brstmspm",
"btsnd",
"bvg",
"caf",
"capdsp",
"cbd2",
"ccc",
"cfn",
"ckd",
"cnk",
"cps",
"dcs",
"de2",
"ddsp",
"dmsg",
"dsp",
"dspw",
"dtk",
"dvi",
"dxh",
"eam",
"emff",
"enth",
"fag",
"filp",
"fsb",
"g1l",
"gbts",
"gca",
"gcm",
"gcub",
"gcw",
"genh",
"gms",
"gsb",
"hgc1",
"his",
"hlwav",
"hps",
"hsf",
"hwas",
"iab",
"idsp",
"idvi",
"ikm",
"ild",
"int",
"isd",
"ivaud",
"ivag",
"ivb",
"joe",
"jstm",
"kces",
"kcey",
"khv",
"klbs",
"kovs",
"kraw",
"leg",
"logg",
"lpcm",
"lps",
"lsf",
"lwav",
"matx",
"mca",
"mcg",
"mi4",
"mib",
"mic",
"mihb",
"mpdsp",
"mpds",
"msa",
"msf",
"mss",
"msvp",
"mtaf",
"mus",
"musc",
"musx",
"mwv",
"mxst",
"myspd",
"ndp",
"ngca",
"npsf",
"nwa",
"omu",
"otm",
"p2bt",
"p3d",
"past",
"pcm",
"pdt",
"pnb",
"pos",
"ps2stm",
"psh",
"psnd",
"psw",
"ras",
"raw",
"rkv",
"rnd",
"rrds",
"rsd",
"rsf",
"rstm",
"rvws",
"rwar",
"rwav",
"rws",
"rwsd",
"rwx",
"rxw",
"s14",
"sab",
"sad",
"sap",
"sc",
"scd",
"sck",
"sd9",
"sdt",
"seg",
"sf0",
"sfl",
"sfs",
"sfx",
"sgb",
"sgd",
"sl3",
"sli",
"smp",
"smpl",
"snd",
"snds",
"sng",
"sns",
"spd",
"spm",
"sps",
"spsd",
"spw",
"ss2",
"ss3",
"ss7",
"ssm",
"sss",
"ster",
"stma",
"str",
"strm",
"sts",
"stx",
"svag",
"svs",
"swav",
"swd",
"tec",
"thp",
"tk1",
"tk5",
"tra",
"tun",
"tydsp",
"um3",
"vag",
"vas",
"vawx",
"vb",
"vbk",
"vgs",
"vgv",
"vig",
"vms",
"voi",
"vpk",
"vs",
"vsf",
"waa",
"wac",
"wad",
"wam",
"wavm",
"wb",
"wii",
"wmus",
"wp2",
"wpd",
"wsd",
"wsi",
"wvs",
"xa",
"xa2",
"xa30",
"xau",
"xmu",
"xnb",
"xsf",
"xss",
"xvag",
"xvas",
"xwav",
"xwb",
"ydsp",
"ymf",
"zsd",
"zwdsp",
/* terminator */
NULL
};
InputPlugin vgmstream_iplug = {
.description = "VGMStream Decoder",
.init = vgmstream_init,
.about = vgmstream_about,
.configure = vgmstream_configure,
.cleanup = vgmstream_destroy,
.probe_for_tuple = vgmstream_probe_for_tuple,
.play_file = vgmstream_play,
.stop = vgmstream_stop,
.pause = vgmstream_pause,
.seek = vgmstream_seek,
.vfs_extensions = vgmstream_exts,
.mseek = vgmstream_mseek,
.file_info_box = vgmstream_file_info_box,
};

View File

@ -46,6 +46,7 @@ const char *vgmstream_exts[] =
"bo2",
"brstm",
"brstmspm",
"btsnd",
"bvg",
"caf",
@ -121,6 +122,7 @@ const char *vgmstream_exts[] =
"lwav",
"matx",
"mca",
"mcg",
"mi4",
"mib",

View File

@ -114,7 +114,7 @@ bool vgmstream_play(const char * filename, VFSFile * file)
int max_buffer_samples = sizeof(buffer) / sizeof(buffer[0]) / vgmstream->channels;
int stream_samples_amount = get_vgmstream_play_samples(vgmstream_cfg.loop_count, vgmstream_cfg.fade_length, vgmstream_cfg.fade_delay, vgmstream);
rate = vgmstream->sample_rate * 2 * vgmstream->channels;
rate = get_vgmstream_average_bitrate(vgmstream);
aud_input_set_bitrate(rate);

View File

@ -1,6 +1,6 @@
export SHELL = /bin/sh
export CFLAGS=-Wall -O3 "-DVGM_USE_G7221" "-DVGM_USE_MAIATRAC3PLUS" -I../ext_includes
export LDFLAGS=-L../src -L../ext_libs -lvgmstream -lvorbis -lmpg123-0 -lg7221_decode -lat3plusdecoder -lm
export CFLAGS=-Wall -O3 "-DVGM_USE_G7221" "-DVGM_USE_G719" "-DVGM_USE_MAIATRAC3PLUS" "-DWIN32" "-DUSE_ALLOCA" -I../ext_includes
export LDFLAGS=-L../src -L../ext_libs -lvgmstream -lvorbis -lmpg123-0 -lg7221_decode -lg719_decode -lat3plusdecoder -lm
export CC=i586-mingw32msvc-gcc
export AR=i586-mingw32msvc-ar
export STRIP=i586-mingw32msvc-strip
@ -11,9 +11,9 @@ export WINDRES=i586-mingw32msvc-windres
#export STRIP=i686-w64-mingw32-strip
#export WINDRES=i686-w64-mingw32-windres
.PHONY: libvgmstream.a libvorbis.a libmpg123-0.a libg7221_decode.a at3plusdecoder.a
.PHONY: libvgmstream.a libvorbis.a libmpg123-0.a libg7221_decode.a libg719_decode.a at3plusdecoder.a
in_vgmstream.dll: libvgmstream.a libvorbis.a libmpg123-0.a libg7221_decode.a in_vgmstream.c resource.o
in_vgmstream.dll: libvgmstream.a libvorbis.a libmpg123-0.a libg7221_decode.a libg719_decode.a in_vgmstream.c resource.o
$(CC) -shared -static-libgcc $(CFLAGS) "-DVERSION=\"`../version.sh`\"" in_vgmstream.c resource.o $(LDFLAGS) -o in_vgmstream.dll
$(STRIP) in_vgmstream.dll
@ -32,6 +32,9 @@ libmpg123-0.a:
libg7221_decode.a:
$(MAKE) -C ../ext_libs -f Makefile.mingw $@
libg719_decode.a:
$(MAKE) -C ../ext_libs -f Makefile.mingw $@
at3plusdecoder.a:
$(MAKE) -C ../ext_libs -f Makefile.mingw $@

View File

@ -502,7 +502,7 @@ int play(char *fn)
/* Set info display */
/* TODO: actual bitrate */
input_module.SetInfo(100,vgmstream->sample_rate/1000,vgmstream->channels,1);
input_module.SetInfo(get_vgmstream_average_bitrate(vgmstream)/1000,vgmstream->sample_rate/1000,vgmstream->channels,1);
/* setup visualization */
input_module.SAVSAInit(max_latency,vgmstream->sample_rate);

View File

@ -61,7 +61,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="../ext_libs/libvorbis.lib ../ext_libs/libmpg123-0.lib ../ext_libs/libg7221_decode.lib"
AdditionalDependencies="../ext_libs/libvorbis.lib ../ext_libs/libmpg123-0.lib ../ext_libs/libg7221_decode.lib ../ext_libs/libg719_decode.lib"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
@ -133,7 +133,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="../ext_libs/libvorbis.lib ../ext_libs/libmpg123-0.lib ../ext_libs/libg7221_decode.lib"
AdditionalDependencies="../ext_libs/libvorbis.lib ../ext_libs/libmpg123-0.lib ../ext_libs/libg7221_decode.lib ../ext_libs/libg719_decode.lib"
LinkIncremental="2"
ModuleDefinitionFile=""
GenerateDebugInformation="true"