Added G.719 decoding support to BNSF input

This commit is contained in:
Chris Moeller 2015-01-24 21:08:25 -08:00
parent 2cafa1a676
commit 1ad884287b
19 changed files with 240 additions and 19 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

@ -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

@ -73,7 +73,7 @@ void decode_ogg_vorbis(ogg_vorbis_codec_data * data, sample * outbuf, int32_t sa
#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC)
void decode_mp4_aac(mp4_aac_codec_data * data, sample * outbuf, int32_t samples_to_do, int channels);
#endif
#endif
void decode_sdx2(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
void decode_sdx2_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
@ -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;USE_ALLOCA;_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;USE_ALLOCA;NDEBUG;_LIB;"
PreprocessorDefinitions="WIN32;VGM_USE_G7221;VGM_USE_G719;USE_ALLOCA;NDEBUG;_LIB;"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="3"
@ -1218,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;USE_ALLOCA;_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;USE_ALLOCA;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>
@ -355,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

@ -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

@ -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");

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;

View File

@ -1,6 +1,6 @@
export SHELL = /bin/sh
export CFLAGS=-Wall -O3 -DVGM_USE_G7221 -DVGM_USE_MAIATRAC3PLUS -DVAR_ARRAYS -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,6 +1,6 @@
export SHELL = /bin/sh
export CFLAGS=-Wall -O3 "-DVGM_USE_G7221" "-DVGM_USE_MAIATRAC3PLUS" "-DWIN32" "-DUSE_ALLOCA" -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

@ -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"