diff --git a/ext_includes/g719.h b/ext_includes/g719.h new file mode 100755 index 00000000..993daf23 --- /dev/null +++ b/ext_includes/g719.h @@ -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 diff --git a/ext_libs/Makefile.mingw b/ext_libs/Makefile.mingw index 7f4912ac..21b8ae3f 100644 --- a/ext_libs/Makefile.mingw +++ b/ext_libs/Makefile.mingw @@ -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 diff --git a/ext_libs/ext_libs.vcproj b/ext_libs/ext_libs.vcproj index 6fadc19c..4b33caae 100644 --- a/ext_libs/ext_libs.vcproj +++ b/ext_libs/ext_libs.vcproj @@ -131,6 +131,30 @@ /> + + + + + + + + diff --git a/ext_libs/ext_libs.vcxproj b/ext_libs/ext_libs.vcxproj index 35a035bd..32628179 100644 --- a/ext_libs/ext_libs.vcxproj +++ b/ext_libs/ext_libs.vcxproj @@ -1,4 +1,4 @@ - + @@ -88,6 +88,16 @@ libg7221_decode.lib;libg7221_decode.exp;%(Outputs) + + Building library stub + lib /def:libg719_decode.def /machine:x86 + + libg719_decode.lib;libg719_decode.exp;%(Outputs) + Building library stub + lib /def:libg719_decode.def /machine:x86 + + libg719_decode.lib;libg719_decode.exp;%(Outputs) + diff --git a/ext_libs/libg719_decode.def b/ext_libs/libg719_decode.def new file mode 100755 index 00000000..9d9bdb79 --- /dev/null +++ b/ext_libs/libg719_decode.def @@ -0,0 +1,6 @@ +LIBRARY libg719_decode.dll +EXPORTS + g719_decode_frame @1 + g719_free @2 + g719_init @3 + g719_reset @4 diff --git a/ext_libs/libg719_decode.dll b/ext_libs/libg719_decode.dll new file mode 100755 index 00000000..d238a4a9 Binary files /dev/null and b/ext_libs/libg719_decode.dll differ diff --git a/src/Makefile b/src/Makefile index 2ebbb724..bc10875b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 \ diff --git a/src/coding/Makefile.unix.am b/src/coding/Makefile.unix.am index 12380feb..3163e6a7 100644 --- a/src/coding/Makefile.unix.am +++ b/src/coding/Makefile.unix.am @@ -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 diff --git a/src/coding/coding.h b/src/coding/coding.h index 14bb20a0..1502d57e 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -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); diff --git a/src/coding/g719_decoder.c b/src/coding/g719_decoder.c new file mode 100644 index 00000000..67a98aed --- /dev/null +++ b/src/coding/g719_decoder.c @@ -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 diff --git a/src/coding/g7221_decoder.c b/src/coding/g7221_decoder.c index a55e4602..6ca80b03 100644 --- a/src/coding/g7221_decoder.c +++ b/src/coding/g7221_decoder.c @@ -1,7 +1,6 @@ #include "../vgmstream.h" #ifdef VGM_USE_G7221 -#include "g7221.h" #include "coding.h" #include "../util.h" diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 69605944..e5dd110b 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -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 @@ + + diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index ea26110a..991787f5 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -56,7 +56,7 @@ Disabled ../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -70,7 +70,7 @@ ../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded @@ -355,6 +355,7 @@ + diff --git a/src/meta/bnsf.c b/src/meta/bnsf.c index de9a59ec..91c020b0 100644 --- a/src/meta/bnsf.c +++ b/src/meta/bnsf.c @@ -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; diff --git a/src/vgmstream.c b/src/vgmstream.c index 8bfea849..c33b9cb9 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -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;chanchannels;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;chanchannels;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"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 91a47b57..3b4b6c43 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -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; diff --git a/test/Makefile.mingw b/test/Makefile.mingw index 2a0f3084..22acf9a3 100644 --- a/test/Makefile.mingw +++ b/test/Makefile.mingw @@ -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: diff --git a/winamp/Makefile b/winamp/Makefile index 389b374f..cca80428 100644 --- a/winamp/Makefile +++ b/winamp/Makefile @@ -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 $@ diff --git a/winamp/in_vgmstream.vcproj b/winamp/in_vgmstream.vcproj index ebe14568..498eafbd 100644 --- a/winamp/in_vgmstream.vcproj +++ b/winamp/in_vgmstream.vcproj @@ -61,7 +61,7 @@ />