From faae95ddcb184572d6ea707a6d0808f1b410b8d0 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sat, 24 Jan 2015 21:22:21 -0800 Subject: [PATCH] Updated vgmstream with support for G.722.1 and G.719 codecs --- .../g719/g719.xcodeproj/project.pbxproj | 456 ++++ Frameworks/g719/g719/Info.plist | 28 + Frameworks/g719/g719/g719.c | 54 + Frameworks/g719/g719/g719.h | 23 + .../g719/reference_code/common/bitalloc.c | 152 ++ .../g719/reference_code/common/bitstream.c | 159 ++ .../g719/reference_code/common/codesearch.c | 66 + .../g719/reference_code/common/common_rom.c | 2164 +++++++++++++++++ .../g719/reference_code/common/complxop.c | 73 + .../g719/g719/reference_code/common/dct.c | 403 +++ .../g719/reference_code/common/idx2code.c | 60 + .../common/interleave_spectrum.c | 165 ++ .../g719/reference_code/common/recovernorm.c | 81 + .../g719/reference_code/common/reordvct.c | 43 + .../g719/g719/reference_code/common/weight.c | 302 +++ .../reference_code/decoder/decode_frame.c | 96 + .../reference_code/decoder/decoder_init.c | 48 + .../g719/reference_code/decoder/decoder_rom.c | 348 +++ .../g719/reference_code/decoder/dprocnf.c | 59 + .../reference_code/decoder/dprocnobitsbfm.c | 106 + .../g719/reference_code/decoder/dqcoefs.c | 104 + .../reference_code/decoder/fill_spectrum.c | 135 + .../g719/reference_code/decoder/flvqdec.c | 180 ++ .../g719/reference_code/decoder/hdeclvq.c | 305 +++ .../g719/reference_code/decoder/hdecnrm.c | 77 + .../g719/reference_code/decoder/trans_inv.c | 141 ++ .../g719/reference_code/decoder/unpackc.c | 119 + .../g719/reference_code/decoder/window_ola.c | 48 + .../g719/g719/reference_code/include/cnst.h | 88 + .../g719/reference_code/include/complxop.h | 25 + .../g719/g719/reference_code/include/proto.h | 359 +++ .../g719/g719/reference_code/include/rom.h | 53 + .../g719/g719/reference_code/include/state.h | 38 + Frameworks/g719/g719/stack_alloc.h | 112 + .../g7221/g7221.xcodeproj/project.pbxproj | 345 +++ Frameworks/g7221/g7221/Info.plist | 28 + Frameworks/g7221/g7221/g7221.c | 43 + Frameworks/g7221/g7221/g7221.h | 23 + Frameworks/g7221/g7221/libsiren/common.c | 529 ++++ Frameworks/g7221/g7221/libsiren/common.h | 146 ++ Frameworks/g7221/g7221/libsiren/dct4.c | 199 ++ Frameworks/g7221/g7221/libsiren/dct4.h | 30 + Frameworks/g7221/g7221/libsiren/decoder.c | 273 +++ Frameworks/g7221/g7221/libsiren/decoder.h | 63 + Frameworks/g7221/g7221/libsiren/encoder.c | 267 ++ Frameworks/g7221/g7221/libsiren/encoder.h | 60 + Frameworks/g7221/g7221/libsiren/huffman.c | 425 ++++ Frameworks/g7221/g7221/libsiren/huffman.h | 42 + .../g7221/g7221/libsiren/huffman_consts.h | 528 ++++ Frameworks/g7221/g7221/libsiren/rmlt.c | 149 ++ Frameworks/g7221/g7221/libsiren/rmlt.h | 30 + Frameworks/g7221/g7221/libsiren/siren7.h | 36 + .../vgmstream.xcodeproj/project.pbxproj | 94 + .../vgmstream/vgmstream/src/coding/coding.h | 5 + .../vgmstream/src/coding/g719_decoder.c | 29 + .../vgmstream/src/coding/g7221_decoder.c | 1 - .../vgmstream/vgmstream/src/meta/bnsf.c | 43 +- .../vgmstream/src/meta/ngc_dsp_std.c | 2 +- .../vgmstream/vgmstream/src/vgmstream.c | 54 + .../vgmstream/vgmstream/src/vgmstream.h | 18 +- 60 files changed, 10127 insertions(+), 5 deletions(-) create mode 100644 Frameworks/g719/g719.xcodeproj/project.pbxproj create mode 100644 Frameworks/g719/g719/Info.plist create mode 100644 Frameworks/g719/g719/g719.c create mode 100755 Frameworks/g719/g719/g719.h create mode 100755 Frameworks/g719/g719/reference_code/common/bitalloc.c create mode 100755 Frameworks/g719/g719/reference_code/common/bitstream.c create mode 100755 Frameworks/g719/g719/reference_code/common/codesearch.c create mode 100755 Frameworks/g719/g719/reference_code/common/common_rom.c create mode 100755 Frameworks/g719/g719/reference_code/common/complxop.c create mode 100755 Frameworks/g719/g719/reference_code/common/dct.c create mode 100755 Frameworks/g719/g719/reference_code/common/idx2code.c create mode 100755 Frameworks/g719/g719/reference_code/common/interleave_spectrum.c create mode 100755 Frameworks/g719/g719/reference_code/common/recovernorm.c create mode 100755 Frameworks/g719/g719/reference_code/common/reordvct.c create mode 100755 Frameworks/g719/g719/reference_code/common/weight.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/decode_frame.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/decoder_init.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/decoder_rom.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/dprocnf.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/dprocnobitsbfm.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/dqcoefs.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/fill_spectrum.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/flvqdec.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/hdeclvq.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/hdecnrm.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/trans_inv.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/unpackc.c create mode 100755 Frameworks/g719/g719/reference_code/decoder/window_ola.c create mode 100755 Frameworks/g719/g719/reference_code/include/cnst.h create mode 100755 Frameworks/g719/g719/reference_code/include/complxop.h create mode 100755 Frameworks/g719/g719/reference_code/include/proto.h create mode 100755 Frameworks/g719/g719/reference_code/include/rom.h create mode 100755 Frameworks/g719/g719/reference_code/include/state.h create mode 100644 Frameworks/g719/g719/stack_alloc.h create mode 100644 Frameworks/g7221/g7221.xcodeproj/project.pbxproj create mode 100644 Frameworks/g7221/g7221/Info.plist create mode 100644 Frameworks/g7221/g7221/g7221.c create mode 100755 Frameworks/g7221/g7221/g7221.h create mode 100644 Frameworks/g7221/g7221/libsiren/common.c create mode 100644 Frameworks/g7221/g7221/libsiren/common.h create mode 100644 Frameworks/g7221/g7221/libsiren/dct4.c create mode 100644 Frameworks/g7221/g7221/libsiren/dct4.h create mode 100644 Frameworks/g7221/g7221/libsiren/decoder.c create mode 100644 Frameworks/g7221/g7221/libsiren/decoder.h create mode 100644 Frameworks/g7221/g7221/libsiren/encoder.c create mode 100644 Frameworks/g7221/g7221/libsiren/encoder.h create mode 100644 Frameworks/g7221/g7221/libsiren/huffman.c create mode 100644 Frameworks/g7221/g7221/libsiren/huffman.h create mode 100644 Frameworks/g7221/g7221/libsiren/huffman_consts.h create mode 100644 Frameworks/g7221/g7221/libsiren/rmlt.c create mode 100644 Frameworks/g7221/g7221/libsiren/rmlt.h create mode 100644 Frameworks/g7221/g7221/libsiren/siren7.h create mode 100644 Frameworks/vgmstream/vgmstream/src/coding/g719_decoder.c diff --git a/Frameworks/g719/g719.xcodeproj/project.pbxproj b/Frameworks/g719/g719.xcodeproj/project.pbxproj new file mode 100644 index 000000000..0fe04e47d --- /dev/null +++ b/Frameworks/g719/g719.xcodeproj/project.pbxproj @@ -0,0 +1,456 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 83D731651A749C5D00CA1366 /* g719.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731411A749C5D00CA1366 /* g719.c */; }; + 83D731661A749C5D00CA1366 /* bitalloc.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731441A749C5D00CA1366 /* bitalloc.c */; }; + 83D731671A749C5D00CA1366 /* bitstream.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731451A749C5D00CA1366 /* bitstream.c */; }; + 83D731681A749C5D00CA1366 /* codesearch.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731461A749C5D00CA1366 /* codesearch.c */; }; + 83D731691A749C5D00CA1366 /* common_rom.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731471A749C5D00CA1366 /* common_rom.c */; }; + 83D7316A1A749C5D00CA1366 /* complxop.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731481A749C5D00CA1366 /* complxop.c */; }; + 83D7316C1A749C5D00CA1366 /* dct.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7314A1A749C5D00CA1366 /* dct.c */; }; + 83D7316D1A749C5D00CA1366 /* idx2code.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7314B1A749C5D00CA1366 /* idx2code.c */; }; + 83D7316E1A749C5D00CA1366 /* interleave_spectrum.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7314C1A749C5D00CA1366 /* interleave_spectrum.c */; }; + 83D7316F1A749C5D00CA1366 /* recovernorm.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7314D1A749C5D00CA1366 /* recovernorm.c */; }; + 83D731701A749C5D00CA1366 /* reordvct.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7314E1A749C5D00CA1366 /* reordvct.c */; }; + 83D731711A749C5D00CA1366 /* weight.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7314F1A749C5D00CA1366 /* weight.c */; }; + 83D731721A749C5D00CA1366 /* decode_frame.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731511A749C5D00CA1366 /* decode_frame.c */; }; + 83D731741A749C5D00CA1366 /* decoder_init.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731531A749C5D00CA1366 /* decoder_init.c */; }; + 83D731751A749C5D00CA1366 /* decoder_rom.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731541A749C5D00CA1366 /* decoder_rom.c */; }; + 83D731761A749C5D00CA1366 /* dprocnf.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731551A749C5D00CA1366 /* dprocnf.c */; }; + 83D731771A749C5D00CA1366 /* dprocnobitsbfm.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731561A749C5D00CA1366 /* dprocnobitsbfm.c */; }; + 83D731781A749C5D00CA1366 /* dqcoefs.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731571A749C5D00CA1366 /* dqcoefs.c */; }; + 83D731791A749C5D00CA1366 /* fill_spectrum.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731581A749C5D00CA1366 /* fill_spectrum.c */; }; + 83D7317A1A749C5D00CA1366 /* flvqdec.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D731591A749C5D00CA1366 /* flvqdec.c */; }; + 83D7317B1A749C5D00CA1366 /* hdeclvq.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7315A1A749C5D00CA1366 /* hdeclvq.c */; }; + 83D7317C1A749C5D00CA1366 /* hdecnrm.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7315B1A749C5D00CA1366 /* hdecnrm.c */; }; + 83D7317D1A749C5D00CA1366 /* trans_inv.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7315C1A749C5D00CA1366 /* trans_inv.c */; }; + 83D7317E1A749C5D00CA1366 /* unpackc.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7315D1A749C5D00CA1366 /* unpackc.c */; }; + 83D7317F1A749C5D00CA1366 /* window_ola.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7315E1A749C5D00CA1366 /* window_ola.c */; }; + 83D731801A749C5D00CA1366 /* cnst.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D731601A749C5D00CA1366 /* cnst.h */; }; + 83D731811A749C5D00CA1366 /* complxop.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D731611A749C5D00CA1366 /* complxop.h */; }; + 83D731821A749C5D00CA1366 /* proto.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D731621A749C5D00CA1366 /* proto.h */; }; + 83D731831A749C5D00CA1366 /* rom.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D731631A749C5D00CA1366 /* rom.h */; }; + 83D731841A749C5D00CA1366 /* state.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D731641A749C5D00CA1366 /* state.h */; }; + 83D731861A749C7800CA1366 /* g719.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D731851A749C7800CA1366 /* g719.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83D7318E1A74A54000CA1366 /* stack_alloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D7318D1A74A54000CA1366 /* stack_alloc.h */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 83D7311C1A74968900CA1366 /* g719.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = g719.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 83D731201A74968900CA1366 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 83D731411A749C5D00CA1366 /* g719.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g719.c; sourceTree = ""; }; + 83D731441A749C5D00CA1366 /* bitalloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bitalloc.c; sourceTree = ""; }; + 83D731451A749C5D00CA1366 /* bitstream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bitstream.c; sourceTree = ""; }; + 83D731461A749C5D00CA1366 /* codesearch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = codesearch.c; sourceTree = ""; }; + 83D731471A749C5D00CA1366 /* common_rom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = common_rom.c; sourceTree = ""; }; + 83D731481A749C5D00CA1366 /* complxop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = complxop.c; sourceTree = ""; }; + 83D7314A1A749C5D00CA1366 /* dct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dct.c; sourceTree = ""; }; + 83D7314B1A749C5D00CA1366 /* idx2code.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = idx2code.c; sourceTree = ""; }; + 83D7314C1A749C5D00CA1366 /* interleave_spectrum.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = interleave_spectrum.c; sourceTree = ""; }; + 83D7314D1A749C5D00CA1366 /* recovernorm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = recovernorm.c; sourceTree = ""; }; + 83D7314E1A749C5D00CA1366 /* reordvct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = reordvct.c; sourceTree = ""; }; + 83D7314F1A749C5D00CA1366 /* weight.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = weight.c; sourceTree = ""; }; + 83D731511A749C5D00CA1366 /* decode_frame.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = decode_frame.c; sourceTree = ""; }; + 83D731531A749C5D00CA1366 /* decoder_init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = decoder_init.c; sourceTree = ""; }; + 83D731541A749C5D00CA1366 /* decoder_rom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = decoder_rom.c; sourceTree = ""; }; + 83D731551A749C5D00CA1366 /* dprocnf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dprocnf.c; sourceTree = ""; }; + 83D731561A749C5D00CA1366 /* dprocnobitsbfm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dprocnobitsbfm.c; sourceTree = ""; }; + 83D731571A749C5D00CA1366 /* dqcoefs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dqcoefs.c; sourceTree = ""; }; + 83D731581A749C5D00CA1366 /* fill_spectrum.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fill_spectrum.c; sourceTree = ""; }; + 83D731591A749C5D00CA1366 /* flvqdec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = flvqdec.c; sourceTree = ""; }; + 83D7315A1A749C5D00CA1366 /* hdeclvq.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hdeclvq.c; sourceTree = ""; }; + 83D7315B1A749C5D00CA1366 /* hdecnrm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hdecnrm.c; sourceTree = ""; }; + 83D7315C1A749C5D00CA1366 /* trans_inv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = trans_inv.c; sourceTree = ""; }; + 83D7315D1A749C5D00CA1366 /* unpackc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = unpackc.c; sourceTree = ""; }; + 83D7315E1A749C5D00CA1366 /* window_ola.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = window_ola.c; sourceTree = ""; }; + 83D731601A749C5D00CA1366 /* cnst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cnst.h; sourceTree = ""; }; + 83D731611A749C5D00CA1366 /* complxop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = complxop.h; sourceTree = ""; }; + 83D731621A749C5D00CA1366 /* proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = proto.h; sourceTree = ""; }; + 83D731631A749C5D00CA1366 /* rom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rom.h; sourceTree = ""; }; + 83D731641A749C5D00CA1366 /* state.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = state.h; sourceTree = ""; }; + 83D731851A749C7800CA1366 /* g719.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = g719.h; sourceTree = ""; }; + 83D7318D1A74A54000CA1366 /* stack_alloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stack_alloc.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 83D731181A74968900CA1366 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 83D731121A74968900CA1366 = { + isa = PBXGroup; + children = ( + 83D7311E1A74968900CA1366 /* g719 */, + 83D7311D1A74968900CA1366 /* Products */, + ); + sourceTree = ""; + }; + 83D7311D1A74968900CA1366 /* Products */ = { + isa = PBXGroup; + children = ( + 83D7311C1A74968900CA1366 /* g719.framework */, + ); + name = Products; + sourceTree = ""; + }; + 83D7311E1A74968900CA1366 /* g719 */ = { + isa = PBXGroup; + children = ( + 83D7318D1A74A54000CA1366 /* stack_alloc.h */, + 83D731851A749C7800CA1366 /* g719.h */, + 83D731411A749C5D00CA1366 /* g719.c */, + 83D731421A749C5D00CA1366 /* reference_code */, + 83D7311F1A74968900CA1366 /* Supporting Files */, + ); + path = g719; + sourceTree = ""; + }; + 83D7311F1A74968900CA1366 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 83D731201A74968900CA1366 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 83D731421A749C5D00CA1366 /* reference_code */ = { + isa = PBXGroup; + children = ( + 83D731431A749C5D00CA1366 /* common */, + 83D731501A749C5D00CA1366 /* decoder */, + 83D7315F1A749C5D00CA1366 /* include */, + ); + path = reference_code; + sourceTree = ""; + }; + 83D731431A749C5D00CA1366 /* common */ = { + isa = PBXGroup; + children = ( + 83D731441A749C5D00CA1366 /* bitalloc.c */, + 83D731451A749C5D00CA1366 /* bitstream.c */, + 83D731461A749C5D00CA1366 /* codesearch.c */, + 83D731471A749C5D00CA1366 /* common_rom.c */, + 83D731481A749C5D00CA1366 /* complxop.c */, + 83D7314A1A749C5D00CA1366 /* dct.c */, + 83D7314B1A749C5D00CA1366 /* idx2code.c */, + 83D7314C1A749C5D00CA1366 /* interleave_spectrum.c */, + 83D7314D1A749C5D00CA1366 /* recovernorm.c */, + 83D7314E1A749C5D00CA1366 /* reordvct.c */, + 83D7314F1A749C5D00CA1366 /* weight.c */, + ); + path = common; + sourceTree = ""; + }; + 83D731501A749C5D00CA1366 /* decoder */ = { + isa = PBXGroup; + children = ( + 83D731511A749C5D00CA1366 /* decode_frame.c */, + 83D731531A749C5D00CA1366 /* decoder_init.c */, + 83D731541A749C5D00CA1366 /* decoder_rom.c */, + 83D731551A749C5D00CA1366 /* dprocnf.c */, + 83D731561A749C5D00CA1366 /* dprocnobitsbfm.c */, + 83D731571A749C5D00CA1366 /* dqcoefs.c */, + 83D731581A749C5D00CA1366 /* fill_spectrum.c */, + 83D731591A749C5D00CA1366 /* flvqdec.c */, + 83D7315A1A749C5D00CA1366 /* hdeclvq.c */, + 83D7315B1A749C5D00CA1366 /* hdecnrm.c */, + 83D7315C1A749C5D00CA1366 /* trans_inv.c */, + 83D7315D1A749C5D00CA1366 /* unpackc.c */, + 83D7315E1A749C5D00CA1366 /* window_ola.c */, + ); + path = decoder; + sourceTree = ""; + }; + 83D7315F1A749C5D00CA1366 /* include */ = { + isa = PBXGroup; + children = ( + 83D731601A749C5D00CA1366 /* cnst.h */, + 83D731611A749C5D00CA1366 /* complxop.h */, + 83D731621A749C5D00CA1366 /* proto.h */, + 83D731631A749C5D00CA1366 /* rom.h */, + 83D731641A749C5D00CA1366 /* state.h */, + ); + path = include; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 83D731191A74968900CA1366 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 83D731861A749C7800CA1366 /* g719.h in Headers */, + 83D731821A749C5D00CA1366 /* proto.h in Headers */, + 83D731831A749C5D00CA1366 /* rom.h in Headers */, + 83D731811A749C5D00CA1366 /* complxop.h in Headers */, + 83D731841A749C5D00CA1366 /* state.h in Headers */, + 83D7318E1A74A54000CA1366 /* stack_alloc.h in Headers */, + 83D731801A749C5D00CA1366 /* cnst.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 83D7311B1A74968900CA1366 /* g719 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 83D731321A74968900CA1366 /* Build configuration list for PBXNativeTarget "g719" */; + buildPhases = ( + 83D731171A74968900CA1366 /* Sources */, + 83D731181A74968900CA1366 /* Frameworks */, + 83D731191A74968900CA1366 /* Headers */, + 83D7311A1A74968900CA1366 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = g719; + productName = g719; + productReference = 83D7311C1A74968900CA1366 /* g719.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 83D731131A74968900CA1366 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + ORGANIZATIONNAME = "Christopher Snowhill"; + TargetAttributes = { + 83D7311B1A74968900CA1366 = { + CreatedOnToolsVersion = 6.1.1; + }; + }; + }; + buildConfigurationList = 83D731161A74968900CA1366 /* Build configuration list for PBXProject "g719" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 83D731121A74968900CA1366; + productRefGroup = 83D7311D1A74968900CA1366 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 83D7311B1A74968900CA1366 /* g719 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 83D7311A1A74968900CA1366 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 83D731171A74968900CA1366 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 83D731691A749C5D00CA1366 /* common_rom.c in Sources */, + 83D7316C1A749C5D00CA1366 /* dct.c in Sources */, + 83D731651A749C5D00CA1366 /* g719.c in Sources */, + 83D7316D1A749C5D00CA1366 /* idx2code.c in Sources */, + 83D731791A749C5D00CA1366 /* fill_spectrum.c in Sources */, + 83D7316F1A749C5D00CA1366 /* recovernorm.c in Sources */, + 83D7317B1A749C5D00CA1366 /* hdeclvq.c in Sources */, + 83D731721A749C5D00CA1366 /* decode_frame.c in Sources */, + 83D731671A749C5D00CA1366 /* bitstream.c in Sources */, + 83D731711A749C5D00CA1366 /* weight.c in Sources */, + 83D731741A749C5D00CA1366 /* decoder_init.c in Sources */, + 83D731751A749C5D00CA1366 /* decoder_rom.c in Sources */, + 83D7316E1A749C5D00CA1366 /* interleave_spectrum.c in Sources */, + 83D7317E1A749C5D00CA1366 /* unpackc.c in Sources */, + 83D731681A749C5D00CA1366 /* codesearch.c in Sources */, + 83D731701A749C5D00CA1366 /* reordvct.c in Sources */, + 83D731661A749C5D00CA1366 /* bitalloc.c in Sources */, + 83D7317D1A749C5D00CA1366 /* trans_inv.c in Sources */, + 83D731761A749C5D00CA1366 /* dprocnf.c in Sources */, + 83D7317C1A749C5D00CA1366 /* hdecnrm.c in Sources */, + 83D7316A1A749C5D00CA1366 /* complxop.c in Sources */, + 83D731771A749C5D00CA1366 /* dprocnobitsbfm.c in Sources */, + 83D7317F1A749C5D00CA1366 /* window_ola.c in Sources */, + 83D731781A749C5D00CA1366 /* dqcoefs.c in Sources */, + 83D7317A1A749C5D00CA1366 /* flvqdec.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 83D731301A74968900CA1366 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 83D731311A74968900CA1366 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 83D731331A74968900CA1366 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "VAR_ARRAYS=1", + ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(PROJECT_DIR)/reference_code/include", + ); + INFOPLIST_FILE = g719/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 83D731341A74968900CA1366 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + GCC_PREPROCESSOR_DEFINITIONS = "VAR_ARRAYS=1"; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(PROJECT_DIR)/reference_code/include", + ); + INFOPLIST_FILE = g719/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 83D731161A74968900CA1366 /* Build configuration list for PBXProject "g719" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83D731301A74968900CA1366 /* Debug */, + 83D731311A74968900CA1366 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 83D731321A74968900CA1366 /* Build configuration list for PBXNativeTarget "g719" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83D731331A74968900CA1366 /* Debug */, + 83D731341A74968900CA1366 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 83D731131A74968900CA1366 /* Project object */; +} diff --git a/Frameworks/g719/g719/Info.plist b/Frameworks/g719/g719/Info.plist new file mode 100644 index 000000000..79dc551e1 --- /dev/null +++ b/Frameworks/g719/g719/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + org.cogx.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSHumanReadableCopyright + Copyright © 2015 Christopher Snowhill. All rights reserved. + NSPrincipalClass + + + diff --git a/Frameworks/g719/g719/g719.c b/Frameworks/g719/g719/g719.c new file mode 100644 index 000000000..ce926a058 --- /dev/null +++ b/Frameworks/g719/g719/g719.c @@ -0,0 +1,54 @@ +// +// g719.c +// g719 +// +// Created by Christopher Snowhill on 1/24/15. +// Copyright (c) 2015 Christopher Snowhill. All rights reserved. +// + +#include + +#include "g719.h" + +#include "proto.h" + +#include "stack_alloc.h" + +struct g719_handle_s +{ + DecoderState state; + int num_bits; +}; + +g719_handle * g719_init(int bytes_per_frame) +{ + g719_handle * handle = (g719_handle *) malloc(sizeof(struct g719_handle_s)); + if (handle) + { + handle->num_bits = bytes_per_frame * 8; + decoder_init(&handle->state, bytes_per_frame * 8); + } + return handle; +} + +void g719_decode_frame(g719_handle *handle, void *code_words, void *sample_buffer) +{ + int i, j; + VARDECL(short, code_bits); + ALLOC(code_bits, handle->num_bits, short); + for (i = 0, j = handle->num_bits; i < j; i++) + { + code_bits[i] = ((((unsigned char *)code_words)[i / 8] >> (i & 7)) & 1) ? G192_BIT1 : G192_BIT0; + } + decode_frame((short *)code_bits, 0, (short *)sample_buffer, &handle->state); +} + +void g719_reset(g719_handle *handle) +{ + decoder_reset_tables(&handle->state, handle->num_bits); +} + +void g719_free(g719_handle *handle) +{ + free(handle); +} diff --git a/Frameworks/g719/g719/g719.h b/Frameworks/g719/g719/g719.h new file mode 100755 index 000000000..993daf237 --- /dev/null +++ b/Frameworks/g719/g719/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/Frameworks/g719/g719/reference_code/common/bitalloc.c b/Frameworks/g719/g719/reference_code/common/bitalloc.c new file mode 100755 index 000000000..eea549ef0 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/common/bitalloc.c @@ -0,0 +1,152 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "cnst.h" +#include "rom.h" + +/*--------------------------------------------------------------------------*/ +/* Function bitalloc */ +/* ~~~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Adaptive bit allocation for 20kHz audio codec */ +/*--------------------------------------------------------------------------*/ +/* short *y (i) reordered norm of sub-vectors */ +/* short *idx (i) reordered sub-vector indices */ +/* short sum (i) number of available bits */ +/* short N (i) number of norms */ +/* short M (i) maximum number of bits per dimension */ +/* short *r (o) bit-allacation vector */ +/*--------------------------------------------------------------------------*/ +void bitalloc(short *y, short *idx, short sum, short N, short M, short *r) +{ + short i, j, k, n, m, v, im; + short diff, temp; + + + im = 1; + diff = sum; + n = sum >> 3; + for (i=0; i=sfmsize[j]) && (r[j]=M) + { + y[k] = MIN16B; + } + sum -= sfmsize[j]; + } + else + { + y[k] = MIN16B; + k++; + if (k==im) + { + im++; + } + } + if ((sumv) + { + for (i=0; iMIN16B) + { + im = i + 1; + break; + } + } + } + } + if (sum>=WID_G2) + { + for (i=0; i=SFM_G1) && (j=WID_G2) + { + for (i=0; i=SFM_G1) && (j=WID_G1) + { + for (i=0; i=WID_G1) + { + for (i=0; i> i) & 1; + y--; + *y = G192_BIT1; + if (temp==0) + { + *y = G192_BIT0; + } + } + + return; +} + + +/*--------------------------------------------------------------------------*/ +/* Function idx2bitsc */ +/* ~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Conversion from quantization index into ITU bit stream */ +/*--------------------------------------------------------------------------*/ +/* short *x (i) quantization index */ +/* short N (i) vector dimensions */ +/* short L (i) bits per coefficient */ +/* short *y (o) ITU bitstream */ +/*--------------------------------------------------------------------------*/ +void idx2bitsc(short *x, short N, short L, short *y) +{ + short i, j, m, n; + short temp; + short *pty; + + + if (L==1) + { + n = 1; + m = N; + } + else + { + n = N; + m = L; + } + + for (j=0; j> i) & 1; + pty--; + *pty = G192_BIT1; + if (temp==0) + { + *pty = G192_BIT0; + } + } + } + + return; +} + +/*--------------------------------------------------------------------------*/ +/* Function bits2idxn */ +/* ~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Conversion from ITU bit stream into norm index */ +/*--------------------------------------------------------------------------*/ +/* short *y i) ITU bitstream */ +/* short N (i) bits per norm */ +/* short *x (o) index of quantized norm */ +/*--------------------------------------------------------------------------*/ +void bits2idxn(short *y, short N, short *x) +{ + short i; + + + *x = 0; + for (i=0; i> FacLVQ2Qv[R]; + if ((temp>FacLVQ2HalfQv[R]) || ((temp==FacLVQ2HalfQv[R]) && (x[i]<0))) + { + C[i] += 1; + } + sum += C[i]; + } + if (sum&1) + { + j = 0; + em = 0; + for (i=0; i<8; i++) + { + temp = C[i] << FacLVQ2Qv[R]; + e[i] = x[i] - temp; + temp = e[i]; + if (e[i]<0) + { + temp = -e[i]; + } + if (em=0) + { + C[j] += 1; + } + else + { + C[j] -= 1; + } + } + + return; +} diff --git a/Frameworks/g719/g719/reference_code/common/common_rom.c b/Frameworks/g719/g719/reference_code/common/common_rom.c new file mode 100755 index 000000000..ddea76492 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/common/common_rom.c @@ -0,0 +1,2164 @@ +/*-----------------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*-----------------------------------------------------------------------------------*/ + +#include "complxop.h" + +float dicn[40]={ /* Codebook for quantization of norms */ +131072.0f, 92681.900024f, +65536.0f, 46340.950012f, +32768.0f, 23170.475006f, +16384.0f, 11585.237503f, +8192.0f, 5792.618751f, +4096.0f, 2896.309376f, +2048.0f, 1448.154688f, +1024.0f, 724.077344f, +512.0f, 362.038672f, +256.0f, 181.019336f, +128.0f, 90.509668f, +64.0f, 45.254834f, +32.0f, 22.627417f, +16.0f, 11.313708f, +8.0f, 5.656854f, +4.0f, 2.828427f, +2.0f, 1.414214f, +1.0f, 0.707107f, +0.5f, 0.353553f, +0.25f, 0.176777f +}; + +float window[1920] = { +0.000823975f, 0.00244141f, 0.00408936f, 0.0057373f, 0.00735474f, 0.00900269f, +0.0106506f, 0.0122681f, 0.013916f, 0.0155334f, 0.0171814f, 0.0188293f, +0.0204468f, 0.0220947f, 0.0237122f, 0.0253601f, 0.0270081f, 0.0286255f, +0.0302734f, 0.0318909f, 0.0335388f, 0.0351868f, 0.0368042f, 0.0384521f, +0.0400696f, 0.0417175f, 0.043335f, 0.0449829f, 0.0466309f, 0.0482483f, +0.0498962f, 0.0515137f, 0.0531616f, 0.0547791f, 0.056427f, 0.0580444f, +0.0596924f, 0.0613098f, 0.0629578f, 0.0645752f, 0.0662231f, 0.0678406f, +0.0694885f, 0.071106f, 0.0727539f, 0.0743713f, 0.0760193f, 0.0776367f, +0.0792847f, 0.0809021f, 0.08255f, 0.0841675f, 0.0857849f, 0.0874329f, +0.0890503f, 0.0906982f, 0.0923157f, 0.0939331f, 0.0955811f, 0.0971985f, +0.0988464f, 0.100464f, 0.102081f, 0.103729f, 0.105347f, 0.106964f, +0.108582f, 0.110229f, 0.111847f, 0.113464f, 0.115112f, 0.11673f, +0.118347f, 0.119965f, 0.121613f, 0.12323f, 0.124847f, 0.126465f, +0.128082f, 0.12973f, 0.131348f, 0.132965f, 0.134583f, 0.1362f, +0.137817f, 0.139435f, 0.141052f, 0.14267f, 0.144287f, 0.145935f, +0.147552f, 0.14917f, 0.150787f, 0.152405f, 0.154022f, 0.15564f, +0.157257f, 0.158844f, 0.160461f, 0.162079f, 0.163696f, 0.165314f, +0.166931f, 0.168549f, 0.170166f, 0.171753f, 0.17337f, 0.174988f, +0.176605f, 0.178223f, 0.17981f, 0.181427f, 0.183044f, 0.184662f, +0.186249f, 0.187866f, 0.189484f, 0.191071f, 0.192688f, 0.194275f, +0.195892f, 0.19751f, 0.199097f, 0.200714f, 0.202301f, 0.203918f, +0.205505f, 0.207123f, 0.20871f, 0.210297f, 0.211914f, 0.213501f, +0.215118f, 0.216705f, 0.218292f, 0.21991f, 0.221497f, 0.223083f, +0.22467f, 0.226288f, 0.227875f, 0.229462f, 0.231049f, 0.232635f, +0.234253f, 0.23584f, 0.237427f, 0.239014f, 0.240601f, 0.242188f, +0.243774f, 0.245361f, 0.246948f, 0.248535f, 0.250122f, 0.251709f, +0.253296f, 0.254852f, 0.256439f, 0.258026f, 0.259613f, 0.2612f, +0.262756f, 0.264343f, 0.26593f, 0.267487f, 0.269073f, 0.27066f, +0.272217f, 0.273804f, 0.27536f, 0.276947f, 0.278534f, 0.28009f, +0.281647f, 0.283234f, 0.28479f, 0.286377f, 0.287933f, 0.28949f, +0.291077f, 0.292633f, 0.294189f, 0.295746f, 0.297333f, 0.298889f, +0.300446f, 0.302002f, 0.303558f, 0.305115f, 0.306671f, 0.308228f, +0.309784f, 0.31134f, 0.312897f, 0.314453f, 0.31601f, 0.317566f, +0.319122f, 0.320679f, 0.322205f, 0.323761f, 0.325317f, 0.326843f, +0.3284f, 0.329956f, 0.331482f, 0.333038f, 0.334564f, 0.336121f, +0.337646f, 0.339203f, 0.340729f, 0.342285f, 0.343811f, 0.345337f, +0.346893f, 0.348419f, 0.349945f, 0.351471f, 0.353027f, 0.354553f, +0.356079f, 0.357605f, 0.359131f, 0.360657f, 0.362183f, 0.363708f, +0.365234f, 0.36676f, 0.368286f, 0.369812f, 0.371307f, 0.372833f, +0.374359f, 0.375885f, 0.37738f, 0.378906f, 0.380402f, 0.381927f, +0.383453f, 0.384949f, 0.386475f, 0.38797f, 0.389465f, 0.390991f, +0.392487f, 0.393982f, 0.395508f, 0.397003f, 0.398499f, 0.399994f, +0.401489f, 0.402985f, 0.40448f, 0.405975f, 0.407471f, 0.408966f, +0.410461f, 0.411957f, 0.413452f, 0.414948f, 0.416443f, 0.417908f, +0.419403f, 0.420898f, 0.422363f, 0.423859f, 0.425323f, 0.426819f, +0.428284f, 0.429779f, 0.431244f, 0.432739f, 0.434204f, 0.435669f, +0.437134f, 0.438629f, 0.440094f, 0.441559f, 0.443024f, 0.444489f, +0.445953f, 0.447418f, 0.448883f, 0.450348f, 0.451813f, 0.453247f, +0.454712f, 0.456177f, 0.457642f, 0.459076f, 0.460541f, 0.462006f, +0.46344f, 0.464905f, 0.466339f, 0.467773f, 0.469238f, 0.470673f, +0.472107f, 0.473572f, 0.475006f, 0.47644f, 0.477875f, 0.479309f, +0.480743f, 0.482178f, 0.483612f, 0.485046f, 0.486481f, 0.487915f, +0.489349f, 0.490753f, 0.492188f, 0.493622f, 0.495026f, 0.49646f, +0.497864f, 0.499298f, 0.500702f, 0.502136f, 0.50354f, 0.504944f, +0.506378f, 0.507782f, 0.509186f, 0.51059f, 0.511993f, 0.513397f, +0.514801f, 0.516205f, 0.517609f, 0.519012f, 0.520416f, 0.52179f, +0.523193f, 0.524597f, 0.52597f, 0.527374f, 0.528748f, 0.530151f, +0.531525f, 0.532928f, 0.534302f, 0.535675f, 0.537079f, 0.538452f, +0.539825f, 0.541199f, 0.542572f, 0.543945f, 0.545319f, 0.546692f, +0.548065f, 0.549438f, 0.550812f, 0.552155f, 0.553528f, 0.554901f, +0.556244f, 0.557617f, 0.55896f, 0.560333f, 0.561676f, 0.563019f, +0.564392f, 0.565735f, 0.567078f, 0.56842f, 0.569763f, 0.571106f, +0.572449f, 0.573792f, 0.575134f, 0.576477f, 0.57782f, 0.579163f, +0.580475f, 0.581818f, 0.58313f, 0.584473f, 0.585785f, 0.587128f, +0.58844f, 0.589783f, 0.591095f, 0.592407f, 0.593719f, 0.595032f, +0.596344f, 0.597656f, 0.598969f, 0.600281f, 0.601593f, 0.602905f, +0.604218f, 0.605499f, 0.606812f, 0.608124f, 0.609406f, 0.610718f, +0.612f, 0.613281f, 0.614594f, 0.615875f, 0.617157f, 0.618439f, +0.619751f, 0.621033f, 0.622314f, 0.623596f, 0.624847f, 0.626129f, +0.627411f, 0.628693f, 0.629944f, 0.631226f, 0.632507f, 0.633759f, +0.63504f, 0.636292f, 0.637543f, 0.638824f, 0.640076f, 0.641327f, +0.642578f, 0.643829f, 0.645081f, 0.646332f, 0.647583f, 0.648834f, +0.650055f, 0.651306f, 0.652557f, 0.653778f, 0.655029f, 0.65625f, +0.657501f, 0.658722f, 0.659973f, 0.661194f, 0.662415f, 0.663635f, +0.664856f, 0.666077f, 0.667297f, 0.668518f, 0.669739f, 0.670959f, +0.67218f, 0.67337f, 0.674591f, 0.675781f, 0.677002f, 0.678192f, +0.679413f, 0.680603f, 0.681793f, 0.682983f, 0.684204f, 0.685394f, +0.686584f, 0.687775f, 0.688934f, 0.690125f, 0.691315f, 0.692505f, +0.693665f, 0.694855f, 0.696045f, 0.697205f, 0.698364f, 0.699554f, +0.700714f, 0.701874f, 0.703033f, 0.704193f, 0.705383f, 0.706543f, +0.707672f, 0.708832f, 0.709991f, 0.711151f, 0.71228f, 0.71344f, +0.7146f, 0.715729f, 0.716858f, 0.718018f, 0.719147f, 0.720276f, +0.721436f, 0.722565f, 0.723694f, 0.724823f, 0.725952f, 0.727051f, +0.72818f, 0.729309f, 0.730438f, 0.731537f, 0.732666f, 0.733765f, +0.734863f, 0.735992f, 0.737091f, 0.73819f, 0.739288f, 0.740387f, +0.741486f, 0.742584f, 0.743683f, 0.744781f, 0.74588f, 0.746979f, +0.748047f, 0.749146f, 0.750214f, 0.751312f, 0.75238f, 0.753448f, +0.754517f, 0.755615f, 0.756683f, 0.757751f, 0.75882f, 0.759888f, +0.760925f, 0.761993f, 0.763062f, 0.764099f, 0.765167f, 0.766205f, +0.767273f, 0.768311f, 0.769379f, 0.770416f, 0.771454f, 0.772491f, +0.773529f, 0.774567f, 0.775604f, 0.776642f, 0.777649f, 0.778687f, +0.779724f, 0.780731f, 0.781769f, 0.782776f, 0.783783f, 0.784821f, +0.785828f, 0.786835f, 0.787842f, 0.788849f, 0.789856f, 0.790863f, +0.79187f, 0.792847f, 0.793854f, 0.79483f, 0.795837f, 0.796814f, +0.797821f, 0.798798f, 0.799774f, 0.800751f, 0.801758f, 0.802734f, +0.80368f, 0.804657f, 0.805634f, 0.80661f, 0.807587f, 0.808533f, +0.809509f, 0.810455f, 0.811401f, 0.812378f, 0.813324f, 0.81427f, +0.815216f, 0.816162f, 0.817108f, 0.818054f, 0.819f, 0.819946f, +0.820862f, 0.821808f, 0.822723f, 0.823669f, 0.824585f, 0.8255f, +0.826447f, 0.827362f, 0.828278f, 0.829193f, 0.830109f, 0.831024f, +0.831909f, 0.832825f, 0.83374f, 0.834625f, 0.835541f, 0.836426f, +0.837341f, 0.838226f, 0.839111f, 0.839996f, 0.840881f, 0.841766f, +0.842651f, 0.843536f, 0.844421f, 0.845276f, 0.846161f, 0.847046f, +0.8479f, 0.848755f, 0.84964f, 0.850494f, 0.851349f, 0.852203f, +0.853058f, 0.853912f, 0.854767f, 0.855621f, 0.856476f, 0.8573f, +0.858154f, 0.858978f, 0.859833f, 0.860657f, 0.861481f, 0.862335f, +0.863159f, 0.863983f, 0.864807f, 0.865631f, 0.866425f, 0.867249f, +0.868073f, 0.868866f, 0.86969f, 0.870483f, 0.871307f, 0.872101f, +0.872894f, 0.873688f, 0.874481f, 0.875275f, 0.876068f, 0.876862f, +0.877655f, 0.878418f, 0.879211f, 0.879974f, 0.880768f, 0.881531f, +0.882294f, 0.883087f, 0.88385f, 0.884613f, 0.885376f, 0.886139f, +0.886871f, 0.887634f, 0.888397f, 0.88913f, 0.889893f, 0.890625f, +0.891388f, 0.89212f, 0.892853f, 0.893585f, 0.894318f, 0.89505f, +0.895782f, 0.896515f, 0.897247f, 0.897949f, 0.898682f, 0.899384f, +0.900116f, 0.900818f, 0.90152f, 0.902222f, 0.902924f, 0.903625f, +0.904327f, 0.905029f, 0.905731f, 0.906433f, 0.907104f, 0.907806f, +0.908478f, 0.90918f, 0.909851f, 0.910522f, 0.911194f, 0.911865f, +0.912537f, 0.913208f, 0.913879f, 0.914551f, 0.915192f, 0.915863f, +0.916504f, 0.917175f, 0.917816f, 0.918457f, 0.919128f, 0.919769f, +0.92041f, 0.921051f, 0.921661f, 0.922302f, 0.922943f, 0.923553f, +0.924194f, 0.924805f, 0.925446f, 0.926056f, 0.926666f, 0.927277f, +0.927887f, 0.928497f, 0.929108f, 0.929718f, 0.930328f, 0.930908f, +0.931519f, 0.932098f, 0.932709f, 0.933289f, 0.933868f, 0.934448f, +0.935028f, 0.935608f, 0.936188f, 0.936768f, 0.937347f, 0.937897f, +0.938477f, 0.939026f, 0.939606f, 0.940155f, 0.940704f, 0.941254f, +0.941833f, 0.942383f, 0.942902f, 0.943451f, 0.944f, 0.94455f, +0.945068f, 0.945618f, 0.946136f, 0.946655f, 0.947205f, 0.947723f, +0.948242f, 0.948761f, 0.94928f, 0.949799f, 0.950287f, 0.950806f, +0.951294f, 0.951813f, 0.952301f, 0.95282f, 0.953308f, 0.953796f, +0.954285f, 0.954773f, 0.955261f, 0.95575f, 0.956238f, 0.956696f, +0.957184f, 0.957642f, 0.95813f, 0.958588f, 0.959045f, 0.959503f, +0.959961f, 0.960419f, 0.960876f, 0.961334f, 0.961792f, 0.962219f, +0.962677f, 0.963104f, 0.963562f, 0.963989f, 0.964417f, 0.964874f, +0.965302f, 0.965729f, 0.966125f, 0.966553f, 0.96698f, 0.967407f, +0.967804f, 0.968201f, 0.968628f, 0.969025f, 0.969421f, 0.969818f, +0.970215f, 0.970612f, 0.971008f, 0.971405f, 0.971802f, 0.972168f, +0.972565f, 0.972931f, 0.973328f, 0.973694f, 0.97406f, 0.974426f, +0.974792f, 0.975159f, 0.975525f, 0.975891f, 0.976227f, 0.976593f, +0.976929f, 0.977295f, 0.977631f, 0.977966f, 0.978333f, 0.978668f, +0.979004f, 0.979309f, 0.979645f, 0.97998f, 0.980316f, 0.980621f, +0.980957f, 0.981262f, 0.981567f, 0.981873f, 0.982208f, 0.982513f, +0.982819f, 0.983093f, 0.983398f, 0.983704f, 0.983978f, 0.984283f, +0.984558f, 0.984863f, 0.985138f, 0.985413f, 0.985687f, 0.985962f, +0.986237f, 0.986511f, 0.986786f, 0.98703f, 0.987305f, 0.987549f, +0.987823f, 0.988068f, 0.988312f, 0.988556f, 0.9888f, 0.989044f, +0.989288f, 0.989532f, 0.989777f, 0.98999f, 0.990234f, 0.990448f, +0.990692f, 0.990906f, 0.991119f, 0.991333f, 0.991547f, 0.99176f, +0.991974f, 0.992188f, 0.992371f, 0.992584f, 0.992767f, 0.992981f, +0.993164f, 0.993347f, 0.99353f, 0.993713f, 0.993896f, 0.99408f, +0.994263f, 0.994446f, 0.994598f, 0.994781f, 0.994934f, 0.995117f, +0.99527f, 0.995422f, 0.995575f, 0.995728f, 0.99588f, 0.996033f, +0.996185f, 0.996307f, 0.99646f, 0.996582f, 0.996735f, 0.996857f, +0.996979f, 0.997101f, 0.997223f, 0.997345f, 0.997467f, 0.997589f, +0.997681f, 0.997803f, 0.997925f, 0.998016f, 0.998108f, 0.99823f, +0.998322f, 0.998413f, 0.998505f, 0.998596f, 0.998657f, 0.998749f, +0.99884f, 0.998901f, 0.998993f, 0.999054f, 0.999115f, 0.999207f, +0.999268f, 0.999329f, 0.99939f, 0.999451f, 0.999481f, 0.999542f, +0.999603f, 0.999634f, 0.999664f, 0.999725f, 0.999756f, 0.999786f, +0.999817f, 0.999847f, 0.999878f, 0.999908f, 0.999939f, 0.999939f, +0.999969f, 0.999969f, 0.999969f, 0.999969f, 0.999969f, 0.999969f, +0.999969f, 0.999969f, 0.999969f, 0.999969f, 0.999969f, 0.999969f, +0.999939f, 0.999939f, 0.999908f, 0.999878f, 0.999847f, 0.999817f, +0.999786f, 0.999756f, 0.999725f, 0.999664f, 0.999634f, 0.999603f, +0.999542f, 0.999481f, 0.999451f, 0.99939f, 0.999329f, 0.999268f, +0.999207f, 0.999115f, 0.999054f, 0.998993f, 0.998901f, 0.99884f, +0.998749f, 0.998657f, 0.998596f, 0.998505f, 0.998413f, 0.998322f, +0.99823f, 0.998108f, 0.998016f, 0.997925f, 0.997803f, 0.997681f, +0.997589f, 0.997467f, 0.997345f, 0.997223f, 0.997101f, 0.996979f, +0.996857f, 0.996735f, 0.996582f, 0.99646f, 0.996307f, 0.996185f, +0.996033f, 0.99588f, 0.995728f, 0.995575f, 0.995422f, 0.99527f, +0.995117f, 0.994934f, 0.994781f, 0.994598f, 0.994446f, 0.994263f, +0.99408f, 0.993896f, 0.993713f, 0.99353f, 0.993347f, 0.993164f, +0.992981f, 0.992767f, 0.992584f, 0.992371f, 0.992188f, 0.991974f, +0.99176f, 0.991547f, 0.991333f, 0.991119f, 0.990906f, 0.990692f, +0.990448f, 0.990234f, 0.98999f, 0.989777f, 0.989532f, 0.989288f, +0.989044f, 0.9888f, 0.988556f, 0.988312f, 0.988068f, 0.987823f, +0.987549f, 0.987305f, 0.98703f, 0.986786f, 0.986511f, 0.986237f, +0.985962f, 0.985687f, 0.985413f, 0.985138f, 0.984863f, 0.984558f, +0.984283f, 0.983978f, 0.983704f, 0.983398f, 0.983093f, 0.982819f, +0.982513f, 0.982208f, 0.981873f, 0.981567f, 0.981262f, 0.980957f, +0.980621f, 0.980316f, 0.97998f, 0.979645f, 0.979309f, 0.979004f, +0.978668f, 0.978333f, 0.977966f, 0.977631f, 0.977295f, 0.976929f, +0.976593f, 0.976227f, 0.975891f, 0.975525f, 0.975159f, 0.974792f, +0.974426f, 0.97406f, 0.973694f, 0.973328f, 0.972931f, 0.972565f, +0.972168f, 0.971802f, 0.971405f, 0.971008f, 0.970612f, 0.970215f, +0.969818f, 0.969421f, 0.969025f, 0.968628f, 0.968201f, 0.967804f, +0.967407f, 0.96698f, 0.966553f, 0.966125f, 0.965729f, 0.965302f, +0.964874f, 0.964417f, 0.963989f, 0.963562f, 0.963104f, 0.962677f, +0.962219f, 0.961792f, 0.961334f, 0.960876f, 0.960419f, 0.959961f, +0.959503f, 0.959045f, 0.958588f, 0.95813f, 0.957642f, 0.957184f, +0.956696f, 0.956238f, 0.95575f, 0.955261f, 0.954773f, 0.954285f, +0.953796f, 0.953308f, 0.95282f, 0.952301f, 0.951813f, 0.951294f, +0.950806f, 0.950287f, 0.949799f, 0.94928f, 0.948761f, 0.948242f, +0.947723f, 0.947205f, 0.946655f, 0.946136f, 0.945618f, 0.945068f, +0.94455f, 0.944f, 0.943451f, 0.942902f, 0.942383f, 0.941833f, +0.941254f, 0.940704f, 0.940155f, 0.939606f, 0.939026f, 0.938477f, +0.937897f, 0.937347f, 0.936768f, 0.936188f, 0.935608f, 0.935028f, +0.934448f, 0.933868f, 0.933289f, 0.932709f, 0.932098f, 0.931519f, +0.930908f, 0.930328f, 0.929718f, 0.929108f, 0.928497f, 0.927887f, +0.927277f, 0.926666f, 0.926056f, 0.925446f, 0.924805f, 0.924194f, +0.923553f, 0.922943f, 0.922302f, 0.921661f, 0.921051f, 0.92041f, +0.919769f, 0.919128f, 0.918457f, 0.917816f, 0.917175f, 0.916504f, +0.915863f, 0.915192f, 0.914551f, 0.913879f, 0.913208f, 0.912537f, +0.911865f, 0.911194f, 0.910522f, 0.909851f, 0.90918f, 0.908478f, +0.907806f, 0.907104f, 0.906433f, 0.905731f, 0.905029f, 0.904327f, +0.903625f, 0.902924f, 0.902222f, 0.90152f, 0.900818f, 0.900116f, +0.899384f, 0.898682f, 0.897949f, 0.897247f, 0.896515f, 0.895782f, +0.89505f, 0.894318f, 0.893585f, 0.892853f, 0.89212f, 0.891388f, +0.890625f, 0.889893f, 0.88913f, 0.888397f, 0.887634f, 0.886871f, +0.886139f, 0.885376f, 0.884613f, 0.88385f, 0.883087f, 0.882294f, +0.881531f, 0.880768f, 0.879974f, 0.879211f, 0.878418f, 0.877655f, +0.876862f, 0.876068f, 0.875275f, 0.874481f, 0.873688f, 0.872894f, +0.872101f, 0.871307f, 0.870483f, 0.86969f, 0.868866f, 0.868073f, +0.867249f, 0.866425f, 0.865631f, 0.864807f, 0.863983f, 0.863159f, +0.862335f, 0.861481f, 0.860657f, 0.859833f, 0.858978f, 0.858154f, +0.8573f, 0.856476f, 0.855621f, 0.854767f, 0.853912f, 0.853058f, +0.852203f, 0.851349f, 0.850494f, 0.84964f, 0.848755f, 0.8479f, +0.847046f, 0.846161f, 0.845276f, 0.844421f, 0.843536f, 0.842651f, +0.841766f, 0.840881f, 0.839996f, 0.839111f, 0.838226f, 0.837341f, +0.836426f, 0.835541f, 0.834625f, 0.83374f, 0.832825f, 0.831909f, +0.831024f, 0.830109f, 0.829193f, 0.828278f, 0.827362f, 0.826447f, +0.8255f, 0.824585f, 0.823669f, 0.822723f, 0.821808f, 0.820862f, +0.819946f, 0.819f, 0.818054f, 0.817108f, 0.816162f, 0.815216f, +0.81427f, 0.813324f, 0.812378f, 0.811401f, 0.810455f, 0.809509f, +0.808533f, 0.807587f, 0.80661f, 0.805634f, 0.804657f, 0.80368f, +0.802734f, 0.801758f, 0.800751f, 0.799774f, 0.798798f, 0.797821f, +0.796814f, 0.795837f, 0.79483f, 0.793854f, 0.792847f, 0.79187f, +0.790863f, 0.789856f, 0.788849f, 0.787842f, 0.786835f, 0.785828f, +0.784821f, 0.783783f, 0.782776f, 0.781769f, 0.780731f, 0.779724f, +0.778687f, 0.777649f, 0.776642f, 0.775604f, 0.774567f, 0.773529f, +0.772491f, 0.771454f, 0.770416f, 0.769379f, 0.768311f, 0.767273f, +0.766205f, 0.765167f, 0.764099f, 0.763062f, 0.761993f, 0.760925f, +0.759888f, 0.75882f, 0.757751f, 0.756683f, 0.755615f, 0.754517f, +0.753448f, 0.75238f, 0.751312f, 0.750214f, 0.749146f, 0.748047f, +0.746979f, 0.74588f, 0.744781f, 0.743683f, 0.742584f, 0.741486f, +0.740387f, 0.739288f, 0.73819f, 0.737091f, 0.735992f, 0.734863f, +0.733765f, 0.732666f, 0.731537f, 0.730438f, 0.729309f, 0.72818f, +0.727051f, 0.725952f, 0.724823f, 0.723694f, 0.722565f, 0.721436f, +0.720276f, 0.719147f, 0.718018f, 0.716858f, 0.715729f, 0.7146f, +0.71344f, 0.71228f, 0.711151f, 0.709991f, 0.708832f, 0.707672f, +0.706543f, 0.705383f, 0.704193f, 0.703033f, 0.701874f, 0.700714f, +0.699554f, 0.698364f, 0.697205f, 0.696045f, 0.694855f, 0.693665f, +0.692505f, 0.691315f, 0.690125f, 0.688934f, 0.687775f, 0.686584f, +0.685394f, 0.684204f, 0.682983f, 0.681793f, 0.680603f, 0.679413f, +0.678192f, 0.677002f, 0.675781f, 0.674591f, 0.67337f, 0.67218f, +0.670959f, 0.669739f, 0.668518f, 0.667297f, 0.666077f, 0.664856f, +0.663635f, 0.662415f, 0.661194f, 0.659973f, 0.658722f, 0.657501f, +0.65625f, 0.655029f, 0.653778f, 0.652557f, 0.651306f, 0.650055f, +0.648834f, 0.647583f, 0.646332f, 0.645081f, 0.643829f, 0.642578f, +0.641327f, 0.640076f, 0.638824f, 0.637543f, 0.636292f, 0.63504f, +0.633759f, 0.632507f, 0.631226f, 0.629944f, 0.628693f, 0.627411f, +0.626129f, 0.624847f, 0.623596f, 0.622314f, 0.621033f, 0.619751f, +0.618439f, 0.617157f, 0.615875f, 0.614594f, 0.613281f, 0.612f, +0.610718f, 0.609406f, 0.608124f, 0.606812f, 0.605499f, 0.604218f, +0.602905f, 0.601593f, 0.600281f, 0.598969f, 0.597656f, 0.596344f, +0.595032f, 0.593719f, 0.592407f, 0.591095f, 0.589783f, 0.58844f, +0.587128f, 0.585785f, 0.584473f, 0.58313f, 0.581818f, 0.580475f, +0.579163f, 0.57782f, 0.576477f, 0.575134f, 0.573792f, 0.572449f, +0.571106f, 0.569763f, 0.56842f, 0.567078f, 0.565735f, 0.564392f, +0.563019f, 0.561676f, 0.560333f, 0.55896f, 0.557617f, 0.556244f, +0.554901f, 0.553528f, 0.552155f, 0.550812f, 0.549438f, 0.548065f, +0.546692f, 0.545319f, 0.543945f, 0.542572f, 0.541199f, 0.539825f, +0.538452f, 0.537079f, 0.535675f, 0.534302f, 0.532928f, 0.531525f, +0.530151f, 0.528748f, 0.527374f, 0.52597f, 0.524597f, 0.523193f, +0.52179f, 0.520416f, 0.519012f, 0.517609f, 0.516205f, 0.514801f, +0.513397f, 0.511993f, 0.51059f, 0.509186f, 0.507782f, 0.506378f, +0.504944f, 0.50354f, 0.502136f, 0.500702f, 0.499298f, 0.497864f, +0.49646f, 0.495026f, 0.493622f, 0.492188f, 0.490753f, 0.489349f, +0.487915f, 0.486481f, 0.485046f, 0.483612f, 0.482178f, 0.480743f, +0.479309f, 0.477875f, 0.47644f, 0.475006f, 0.473572f, 0.472107f, +0.470673f, 0.469238f, 0.467773f, 0.466339f, 0.464905f, 0.46344f, +0.462006f, 0.460541f, 0.459076f, 0.457642f, 0.456177f, 0.454712f, +0.453247f, 0.451813f, 0.450348f, 0.448883f, 0.447418f, 0.445953f, +0.444489f, 0.443024f, 0.441559f, 0.440094f, 0.438629f, 0.437134f, +0.435669f, 0.434204f, 0.432739f, 0.431244f, 0.429779f, 0.428284f, +0.426819f, 0.425323f, 0.423859f, 0.422363f, 0.420898f, 0.419403f, +0.417908f, 0.416443f, 0.414948f, 0.413452f, 0.411957f, 0.410461f, +0.408966f, 0.407471f, 0.405975f, 0.40448f, 0.402985f, 0.401489f, +0.399994f, 0.398499f, 0.397003f, 0.395508f, 0.393982f, 0.392487f, +0.390991f, 0.389465f, 0.38797f, 0.386475f, 0.384949f, 0.383453f, +0.381927f, 0.380402f, 0.378906f, 0.37738f, 0.375885f, 0.374359f, +0.372833f, 0.371307f, 0.369812f, 0.368286f, 0.36676f, 0.365234f, +0.363708f, 0.362183f, 0.360657f, 0.359131f, 0.357605f, 0.356079f, +0.354553f, 0.353027f, 0.351471f, 0.349945f, 0.348419f, 0.346893f, +0.345337f, 0.343811f, 0.342285f, 0.340729f, 0.339203f, 0.337646f, +0.336121f, 0.334564f, 0.333038f, 0.331482f, 0.329956f, 0.3284f, +0.326843f, 0.325317f, 0.323761f, 0.322205f, 0.320679f, 0.319122f, +0.317566f, 0.31601f, 0.314453f, 0.312897f, 0.31134f, 0.309784f, +0.308228f, 0.306671f, 0.305115f, 0.303558f, 0.302002f, 0.300446f, +0.298889f, 0.297333f, 0.295746f, 0.294189f, 0.292633f, 0.291077f, +0.28949f, 0.287933f, 0.286377f, 0.28479f, 0.283234f, 0.281647f, +0.28009f, 0.278534f, 0.276947f, 0.27536f, 0.273804f, 0.272217f, +0.27066f, 0.269073f, 0.267487f, 0.26593f, 0.264343f, 0.262756f, +0.2612f, 0.259613f, 0.258026f, 0.256439f, 0.254852f, 0.253296f, +0.251709f, 0.250122f, 0.248535f, 0.246948f, 0.245361f, 0.243774f, +0.242188f, 0.240601f, 0.239014f, 0.237427f, 0.23584f, 0.234253f, +0.232635f, 0.231049f, 0.229462f, 0.227875f, 0.226288f, 0.22467f, +0.223083f, 0.221497f, 0.21991f, 0.218292f, 0.216705f, 0.215118f, +0.213501f, 0.211914f, 0.210297f, 0.20871f, 0.207123f, 0.205505f, +0.203918f, 0.202301f, 0.200714f, 0.199097f, 0.19751f, 0.195892f, +0.194275f, 0.192688f, 0.191071f, 0.189484f, 0.187866f, 0.186249f, +0.184662f, 0.183044f, 0.181427f, 0.17981f, 0.178223f, 0.176605f, +0.174988f, 0.17337f, 0.171753f, 0.170166f, 0.168549f, 0.166931f, +0.165314f, 0.163696f, 0.162079f, 0.160461f, 0.158844f, 0.157257f, +0.15564f, 0.154022f, 0.152405f, 0.150787f, 0.14917f, 0.147552f, +0.145935f, 0.144287f, 0.14267f, 0.141052f, 0.139435f, 0.137817f, +0.1362f, 0.134583f, 0.132965f, 0.131348f, 0.12973f, 0.128082f, +0.126465f, 0.124847f, 0.12323f, 0.121613f, 0.119965f, 0.118347f, +0.11673f, 0.115112f, 0.113464f, 0.111847f, 0.110229f, 0.108582f, +0.106964f, 0.105347f, 0.103729f, 0.102081f, 0.100464f, 0.0988464f, +0.0971985f, 0.0955811f, 0.0939331f, 0.0923157f, 0.0906982f, 0.0890503f, +0.0874329f, 0.0857849f, 0.0841675f, 0.08255f, 0.0809021f, 0.0792847f, +0.0776367f, 0.0760193f, 0.0743713f, 0.0727539f, 0.071106f, 0.0694885f, +0.0678406f, 0.0662231f, 0.0645752f, 0.0629578f, 0.0613098f, 0.0596924f, +0.0580444f, 0.056427f, 0.0547791f, 0.0531616f, 0.0515137f, 0.0498962f, +0.0482483f, 0.0466309f, 0.0449829f, 0.043335f, 0.0417175f, 0.0400696f, +0.0384521f, 0.0368042f, 0.0351868f, 0.0335388f, 0.0318909f, 0.0302734f, +0.0286255f, 0.0270081f, 0.0253601f, 0.0237122f, 0.0220947f, 0.0204468f, +0.0188293f, 0.0171814f, 0.0155334f, 0.013916f, 0.0122681f, 0.0106506f, +0.00900269f, 0.00735474f, 0.0057373f, 0.00408936f, 0.00244141f, 0.000823975f +}; + +int indxPre[120] = { + 0, 15, 30, 45, 60, 75, 90, 105, 40, 55, + 70, 85, 100, 115, 10, 25, 80, 95, 110, 5, + 20, 35, 50, 65, 24, 39, 54, 69, 84, 99, +114, 9, 64, 79, 94, 109, 4, 19, 34, 49, +104, 119, 14, 29, 44, 59, 74, 89, 48, 63, + 78, 93, 108, 3, 18, 33, 88, 103, 118, 13, + 28, 43, 58, 73, 8, 23, 38, 53, 68, 83, + 98, 113, 72, 87, 102, 117, 12, 27, 42, 57, +112, 7, 22, 37, 52, 67, 82, 97, 32, 47, + 62, 77, 92, 107, 2, 17, 96, 111, 6, 21, + 36, 51, 66, 81, 16, 31, 46, 61, 76, 91, +106, 1, 56, 71, 86, 101, 116, 11, 26, 41 +}; + +int indxPost[120] = { + 0, 105, 90, 75, 60, 45, 30, 15, 40, 25, + 10, 115, 100, 85, 70, 55, 80, 65, 50, 35, + 20, 5, 110, 95, 96, 81, 66, 51, 36, 21, + 6, 111, 16, 1, 106, 91, 76, 61, 46, 31, + 56, 41, 26, 11, 116, 101, 86, 71, 72, 57, + 42, 27, 12, 117, 102, 87, 112, 97, 82, 67, + 52, 37, 22, 7, 32, 17, 2, 107, 92, 77, + 62, 47, 48, 33, 18, 3, 108, 93, 78, 63, + 88, 73, 58, 43, 28, 13, 118, 103, 8, 113, + 98, 83, 68, 53, 38, 23, 24, 9, 114, 99, + 84, 69, 54, 39, 64, 49, 34, 19, 4, 109, + 94, 79, 104, 89, 74, 59, 44, 29, 14, 119 +}; + +float fft120cnst[144] = { +0.25f, 0.25f, 0.25f, -0.25f, 0.25f, -0.176758f, -0.25f, 0.176758f, +-0.375f, -0.375f, -0.375f, 0.375f, -0.375f, 0.265167f, 0.375f, -0.265167f, +-0.216492f, -0.216492f, -0.216492f, 0.216492f, -0.216492f, 0.153076f, 0.216492f, -0.153076f, +-0.3125f, -0.3125f, -0.3125f, 0.3125f, -0.3125f, 0.220978f, 0.3125f, -0.220978f, +0.46875f, 0.46875f, 0.46875f, -0.46875f, 0.46875f, -0.331451f, -0.46875f, 0.331451f, +0.27063f, 0.27063f, 0.27063f, -0.27063f, 0.27063f, -0.191376f, -0.27063f, 0.191376f, +-0.384705f, -0.384705f, -0.384705f, 0.384705f, -0.384705f, 0.272034f, 0.384705f, -0.272034f, +0.577057f, 0.577057f, 0.577057f, -0.577057f, 0.577057f, -0.40802f, -0.577057f, 0.40802f, +0.33316f, 0.33316f, 0.33316f, -0.33316f, 0.33316f, -0.235565f, -0.33316f, 0.235565f, +0.13974f, 0.13974f, 0.13974f, -0.13974f, 0.13974f, -0.0988159f, -0.13974f, 0.0988159f, +-0.209625f, -0.209625f, -0.209625f, 0.209625f, -0.209625f, 0.148224f, 0.209625f, -0.148224f, +-0.121033f, -0.121033f, -0.121033f, 0.121033f, -0.121033f, 0.0855713f, 0.121033f, -0.0855713f, +0.0908203f, 0.0908203f, 0.0908203f, -0.0908203f, 0.0908203f, -0.064209f, -0.0908203f, 0.064209f, +-0.13623f, -0.13623f, -0.13623f, 0.13623f, -0.13623f, 0.0963135f, 0.13623f, -0.0963135f, +-0.0786438f, -0.0786438f, -0.0786438f, 0.0786438f, -0.0786438f, 0.055603f, 0.0786438f, -0.055603f, +0.146942f, 0.146942f, 0.146942f, -0.146942f, 0.146942f, -0.103912f, -0.146942f, 0.103912f, +-0.220398f, -0.220398f, -0.220398f, 0.220398f, -0.220398f, 0.155853f, 0.220398f, -0.155853f, +-0.127258f, -0.127258f, -0.127258f, 0.127258f, -0.127258f, 0.0899963f, 0.127258f, -0.0899963f +}; + +complex ptwdf[480] = { +0.999969f, 0.0f, +0.999969f, 0.0f, +0.999969f, 0.0f, +0.999969f, 0.0f, +0.999969f, 0.0f, +0.999908f, -0.013092f, +0.999664f, -0.0261841f, +0.999237f, -0.0392456f, +0.999969f, 0.0f, +0.999664f, -0.0261841f, +0.998627f, -0.0523376f, +0.996918f, -0.0784607f, +0.999969f, 0.0f, +0.999237f, -0.0392456f, +0.996918f, -0.0784607f, +0.993073f, -0.117523f, +0.999969f, 0.0f, +0.998627f, -0.0523376f, +0.994507f, -0.104523f, +0.987701f, -0.156433f, +0.999969f, 0.0f, +0.997864f, -0.0653992f, +0.991455f, -0.130524f, +0.980774f, -0.195099f, +0.999969f, 0.0f, +0.996918f, -0.0784607f, +0.987701f, -0.156433f, +0.972382f, -0.233459f, +0.999969f, 0.0f, +0.995819f, -0.0914917f, +0.983246f, -0.18222f, +0.962463f, -0.271454f, +0.999969f, 0.0f, +0.994507f, -0.104523f, +0.978149f, -0.207916f, +0.95105f, -0.309021f, +0.999969f, 0.0f, +0.993073f, -0.117523f, +0.972382f, -0.233459f, +0.938202f, -0.34613f, +0.999969f, 0.0f, +0.991455f, -0.130524f, +0.965912f, -0.25882f, +0.923889f, -0.38269f, +0.999969f, 0.0f, +0.989655f, -0.143494f, +0.958832f, -0.284027f, +0.908142f, -0.418671f, +0.999969f, 0.0f, +0.987701f, -0.156433f, +0.95105f, -0.309021f, +0.891022f, -0.453979f, +0.999969f, 0.0f, +0.985565f, -0.169342f, +0.942627f, -0.333801f, +0.872498f, -0.488617f, +0.999969f, 0.0f, +0.983246f, -0.18222f, +0.933594f, -0.358368f, +0.852631f, -0.522491f, +0.999969f, 0.0f, +0.980774f, -0.195099f, +0.923889f, -0.38269f, +0.831482f, -0.555573f, +0.999969f, 0.0f, +0.978149f, -0.207916f, +0.913544f, -0.406738f, +0.809021f, -0.587799f, +0.999969f, 0.0f, +0.975342f, -0.220703f, +0.902588f, -0.430511f, +0.785309f, -0.61908f, +0.999969f, 0.0f, +0.972382f, -0.233459f, +0.891022f, -0.453979f, +0.760406f, -0.649445f, +0.999969f, 0.0f, +0.969238f, -0.246155f, +0.878815f, -0.477173f, +0.734314f, -0.678802f, +0.999969f, 0.0f, +0.965912f, -0.25882f, +0.866028f, -0.5f, +0.707092f, -0.707092f, +0.999969f, 0.0f, +0.962463f, -0.271454f, +0.852631f, -0.522491f, +0.678802f, -0.734314f, +0.999969f, 0.0f, +0.958832f, -0.284027f, +0.838684f, -0.544647f, +0.649445f, -0.760406f, +0.999969f, 0.0f, +0.955017f, -0.296539f, +0.824127f, -0.566406f, +0.61908f, -0.785309f, +0.999969f, 0.0f, +0.95105f, -0.309021f, +0.809021f, -0.587799f, +0.587799f, -0.809021f, +0.999969f, 0.0f, +0.94693f, -0.321442f, +0.793365f, -0.608765f, +0.555573f, -0.831482f, +0.999969f, 0.0f, +0.942627f, -0.333801f, +0.777161f, -0.629333f, +0.522491f, -0.852631f, +0.999969f, 0.0f, +0.938202f, -0.34613f, +0.760406f, -0.649445f, +0.488617f, -0.872498f, +0.999969f, 0.0f, +0.933594f, -0.358368f, +0.743134f, -0.669128f, +0.453979f, -0.891022f, +0.999969f, 0.0f, +0.928802f, -0.370544f, +0.725372f, -0.688354f, +0.418671f, -0.908142f, +0.999969f, 0.0f, +0.923889f, -0.38269f, +0.707092f, -0.707092f, +0.38269f, -0.923889f, +0.999969f, 0.0f, +0.918793f, -0.394745f, +0.688354f, -0.725372f, +0.34613f, -0.938202f, +0.999969f, 0.0f, +0.913544f, -0.406738f, +0.669128f, -0.743134f, +0.309021f, -0.95105f, +0.999969f, 0.0f, +0.908142f, -0.418671f, +0.649445f, -0.760406f, +0.271454f, -0.962463f, +0.999969f, 0.0f, +0.902588f, -0.430511f, +0.629333f, -0.777161f, +0.233459f, -0.972382f, +0.999969f, 0.0f, +0.896881f, -0.442291f, +0.608765f, -0.793365f, +0.195099f, -0.980774f, +0.999969f, 0.0f, +0.891022f, -0.453979f, +0.587799f, -0.809021f, +0.156433f, -0.987701f, +0.999969f, 0.0f, +0.884979f, -0.465607f, +0.566406f, -0.824127f, +0.117523f, -0.993073f, +0.999969f, 0.0f, +0.878815f, -0.477173f, +0.544647f, -0.838684f, +0.0784607f, -0.996918f, +0.999969f, 0.0f, +0.872498f, -0.488617f, +0.522491f, -0.852631f, +0.0392456f, -0.999237f, +0.999969f, 0.0f, +0.866028f, -0.5f, +0.5f, -0.866028f, +0.0f, -1.0f, +0.999969f, 0.0f, +0.859406f, -0.511292f, +0.477173f, -0.878815f, +-0.0392456f, -0.999237f, +0.999969f, 0.0f, +0.852631f, -0.522491f, +0.453979f, -0.891022f, +-0.0784607f, -0.996918f, +0.999969f, 0.0f, +0.845734f, -0.5336f, +0.430511f, -0.902588f, +-0.117523f, -0.993073f, +0.999969f, 0.0f, +0.838684f, -0.544647f, +0.406738f, -0.913544f, +-0.156433f, -0.987701f, +0.999969f, 0.0f, +0.831482f, -0.555573f, +0.38269f, -0.923889f, +-0.195099f, -0.980774f, +0.999969f, 0.0f, +0.824127f, -0.566406f, +0.358368f, -0.933594f, +-0.233459f, -0.972382f, +0.999969f, 0.0f, +0.81665f, -0.577148f, +0.333801f, -0.942627f, +-0.271454f, -0.962463f, +0.999969f, 0.0f, +0.809021f, -0.587799f, +0.309021f, -0.95105f, +-0.309021f, -0.95105f, +0.999969f, 0.0f, +0.801239f, -0.598328f, +0.284027f, -0.958832f, +-0.34613f, -0.938202f, +0.999969f, 0.0f, +0.793365f, -0.608765f, +0.25882f, -0.965912f, +-0.38269f, -0.923889f, +0.999969f, 0.0f, +0.785309f, -0.61908f, +0.233459f, -0.972382f, +-0.418671f, -0.908142f, +0.999969f, 0.0f, +0.777161f, -0.629333f, +0.207916f, -0.978149f, +-0.453979f, -0.891022f, +0.999969f, 0.0f, +0.768829f, -0.639435f, +0.18222f, -0.983246f, +-0.488617f, -0.872498f, +0.999969f, 0.0f, +0.760406f, -0.649445f, +0.156433f, -0.987701f, +-0.522491f, -0.852631f, +0.999969f, 0.0f, +0.751831f, -0.659332f, +0.130524f, -0.991455f, +-0.555573f, -0.831482f, +0.999969f, 0.0f, +0.743134f, -0.669128f, +0.104523f, -0.994507f, +-0.587799f, -0.809021f, +0.999969f, 0.0f, +0.734314f, -0.678802f, +0.0784607f, -0.996918f, +-0.61908f, -0.785309f, +0.999969f, 0.0f, +0.725372f, -0.688354f, +0.0523376f, -0.998627f, +-0.649445f, -0.760406f, +0.999969f, 0.0f, +0.716309f, -0.697784f, +0.0261841f, -0.999664f, +-0.678802f, -0.734314f, +0.999969f, 0.0f, +0.707092f, -0.707092f, +0.0f, -1.0f, +-0.707092f, -0.707092f, +0.999969f, 0.0f, +0.697784f, -0.716309f, +-0.0261841f, -0.999664f, +-0.734314f, -0.678802f, +0.999969f, 0.0f, +0.688354f, -0.725372f, +-0.0523376f, -0.998627f, +-0.760406f, -0.649445f, +0.999969f, 0.0f, +0.678802f, -0.734314f, +-0.0784607f, -0.996918f, +-0.785309f, -0.61908f, +0.999969f, 0.0f, +0.669128f, -0.743134f, +-0.104523f, -0.994507f, +-0.809021f, -0.587799f, +0.999969f, 0.0f, +0.659332f, -0.751831f, +-0.130524f, -0.991455f, +-0.831482f, -0.555573f, +0.999969f, 0.0f, +0.649445f, -0.760406f, +-0.156433f, -0.987701f, +-0.852631f, -0.522491f, +0.999969f, 0.0f, +0.639435f, -0.768829f, +-0.18222f, -0.983246f, +-0.872498f, -0.488617f, +0.999969f, 0.0f, +0.629333f, -0.777161f, +-0.207916f, -0.978149f, +-0.891022f, -0.453979f, +0.999969f, 0.0f, +0.61908f, -0.785309f, +-0.233459f, -0.972382f, +-0.908142f, -0.418671f, +0.999969f, 0.0f, +0.608765f, -0.793365f, +-0.25882f, -0.965912f, +-0.923889f, -0.38269f, +0.999969f, 0.0f, +0.598328f, -0.801239f, +-0.284027f, -0.958832f, +-0.938202f, -0.34613f, +0.999969f, 0.0f, +0.587799f, -0.809021f, +-0.309021f, -0.95105f, +-0.95105f, -0.309021f, +0.999969f, 0.0f, +0.577148f, -0.81665f, +-0.333801f, -0.942627f, +-0.962463f, -0.271454f, +0.999969f, 0.0f, +0.566406f, -0.824127f, +-0.358368f, -0.933594f, +-0.972382f, -0.233459f, +0.999969f, 0.0f, +0.555573f, -0.831482f, +-0.38269f, -0.923889f, +-0.980774f, -0.195099f, +0.999969f, 0.0f, +0.544647f, -0.838684f, +-0.406738f, -0.913544f, +-0.987701f, -0.156433f, +0.999969f, 0.0f, +0.5336f, -0.845734f, +-0.430511f, -0.902588f, +-0.993073f, -0.117523f, +0.999969f, 0.0f, +0.522491f, -0.852631f, +-0.453979f, -0.891022f, +-0.996918f, -0.0784607f, +0.999969f, 0.0f, +0.511292f, -0.859406f, +-0.477173f, -0.878815f, +-0.999237f, -0.0392456f, +0.999969f, 0.0f, +0.5f, -0.866028f, +-0.5f, -0.866028f, +-1.0f, 0.0f, +0.999969f, 0.0f, +0.488617f, -0.872498f, +-0.522491f, -0.852631f, +-0.999237f, 0.0392456f, +0.999969f, 0.0f, +0.477173f, -0.878815f, +-0.544647f, -0.838684f, +-0.996918f, 0.0784607f, +0.999969f, 0.0f, +0.465607f, -0.884979f, +-0.566406f, -0.824127f, +-0.993073f, 0.117523f, +0.999969f, 0.0f, +0.453979f, -0.891022f, +-0.587799f, -0.809021f, +-0.987701f, 0.156433f, +0.999969f, 0.0f, +0.442291f, -0.896881f, +-0.608765f, -0.793365f, +-0.980774f, 0.195099f, +0.999969f, 0.0f, +0.430511f, -0.902588f, +-0.629333f, -0.777161f, +-0.972382f, 0.233459f, +0.999969f, 0.0f, +0.418671f, -0.908142f, +-0.649445f, -0.760406f, +-0.962463f, 0.271454f, +0.999969f, 0.0f, +0.406738f, -0.913544f, +-0.669128f, -0.743134f, +-0.95105f, 0.309021f, +0.999969f, 0.0f, +0.394745f, -0.918793f, +-0.688354f, -0.725372f, +-0.938202f, 0.34613f, +0.999969f, 0.0f, +0.38269f, -0.923889f, +-0.707092f, -0.707092f, +-0.923889f, 0.38269f, +0.999969f, 0.0f, +0.370544f, -0.928802f, +-0.725372f, -0.688354f, +-0.908142f, 0.418671f, +0.999969f, 0.0f, +0.358368f, -0.933594f, +-0.743134f, -0.669128f, +-0.891022f, 0.453979f, +0.999969f, 0.0f, +0.34613f, -0.938202f, +-0.760406f, -0.649445f, +-0.872498f, 0.488617f, +0.999969f, 0.0f, +0.333801f, -0.942627f, +-0.777161f, -0.629333f, +-0.852631f, 0.522491f, +0.999969f, 0.0f, +0.321442f, -0.94693f, +-0.793365f, -0.608765f, +-0.831482f, 0.555573f, +0.999969f, 0.0f, +0.309021f, -0.95105f, +-0.809021f, -0.587799f, +-0.809021f, 0.587799f, +0.999969f, 0.0f, +0.296539f, -0.955017f, +-0.824127f, -0.566406f, +-0.785309f, 0.61908f, +0.999969f, 0.0f, +0.284027f, -0.958832f, +-0.838684f, -0.544647f, +-0.760406f, 0.649445f, +0.999969f, 0.0f, +0.271454f, -0.962463f, +-0.852631f, -0.522491f, +-0.734314f, 0.678802f, +0.999969f, 0.0f, +0.25882f, -0.965912f, +-0.866028f, -0.5f, +-0.707092f, 0.707092f, +0.999969f, 0.0f, +0.246155f, -0.969238f, +-0.878815f, -0.477173f, +-0.678802f, 0.734314f, +0.999969f, 0.0f, +0.233459f, -0.972382f, +-0.891022f, -0.453979f, +-0.649445f, 0.760406f, +0.999969f, 0.0f, +0.220703f, -0.975342f, +-0.902588f, -0.430511f, +-0.61908f, 0.785309f, +0.999969f, 0.0f, +0.207916f, -0.978149f, +-0.913544f, -0.406738f, +-0.587799f, 0.809021f, +0.999969f, 0.0f, +0.195099f, -0.980774f, +-0.923889f, -0.38269f, +-0.555573f, 0.831482f, +0.999969f, 0.0f, +0.18222f, -0.983246f, +-0.933594f, -0.358368f, +-0.522491f, 0.852631f, +0.999969f, 0.0f, +0.169342f, -0.985565f, +-0.942627f, -0.333801f, +-0.488617f, 0.872498f, +0.999969f, 0.0f, +0.156433f, -0.987701f, +-0.95105f, -0.309021f, +-0.453979f, 0.891022f, +0.999969f, 0.0f, +0.143494f, -0.989655f, +-0.958832f, -0.284027f, +-0.418671f, 0.908142f, +0.999969f, 0.0f, +0.130524f, -0.991455f, +-0.965912f, -0.25882f, +-0.38269f, 0.923889f, +0.999969f, 0.0f, +0.117523f, -0.993073f, +-0.972382f, -0.233459f, +-0.34613f, 0.938202f, +0.999969f, 0.0f, +0.104523f, -0.994507f, +-0.978149f, -0.207916f, +-0.309021f, 0.95105f, +0.999969f, 0.0f, +0.0914917f, -0.995819f, +-0.983246f, -0.18222f, +-0.271454f, 0.962463f, +0.999969f, 0.0f, +0.0784607f, -0.996918f, +-0.987701f, -0.156433f, +-0.233459f, 0.972382f, +0.999969f, 0.0f, +0.0653992f, -0.997864f, +-0.991455f, -0.130524f, +-0.195099f, 0.980774f, +0.999969f, 0.0f, +0.0523376f, -0.998627f, +-0.994507f, -0.104523f, +-0.156433f, 0.987701f, +0.999969f, 0.0f, +0.0392456f, -0.999237f, +-0.996918f, -0.0784607f, +-0.117523f, 0.993073f, +0.999969f, 0.0f, +0.0261841f, -0.999664f, +-0.998627f, -0.0523376f, +-0.0784607f, 0.996918f, +0.999969f, 0.0f, +0.013092f, -0.999908f, +-0.999664f, -0.0261841f, +-0.0392456f, 0.999237f +}; + + +complex dct120_table_1[120] = { +0.730286f, -0.00238037f, +0.730194f, -0.0119629f, +0.72998f, -0.0215149f, +0.729614f, -0.0310669f, +0.729156f, -0.0406189f, +0.728577f, -0.0501404f, +0.727844f, -0.0596924f, +0.72699f, -0.0692139f, +0.726044f, -0.0787048f, +0.724945f, -0.0881958f, +0.723724f, -0.0976868f, +0.722382f, -0.107147f, +0.720917f, -0.116608f, +0.71933f, -0.126038f, +0.717621f, -0.135437f, +0.71579f, -0.144806f, +0.713837f, -0.154175f, +0.711761f, -0.163513f, +0.709534f, -0.172791f, +0.707214f, -0.182068f, +0.704773f, -0.191315f, +0.702209f, -0.200531f, +0.699524f, -0.209717f, +0.696716f, -0.218842f, +0.693787f, -0.227936f, +0.690765f, -0.237f, +0.687592f, -0.246033f, +0.684326f, -0.255005f, +0.680908f, -0.263947f, +0.677399f, -0.272827f, +0.673767f, -0.281677f, +0.670044f, -0.290466f, +0.666168f, -0.299225f, +0.662201f, -0.307922f, +0.658112f, -0.316559f, +0.6539f, -0.325134f, +0.649597f, -0.333679f, +0.645172f, -0.342133f, +0.640656f, -0.350555f, +0.635986f, -0.358917f, +0.631256f, -0.367218f, +0.626373f, -0.375427f, +0.621429f, -0.383606f, +0.616333f, -0.391724f, +0.611176f, -0.39975f, +0.605865f, -0.407715f, +0.600494f, -0.415619f, +0.595001f, -0.423431f, +0.589417f, -0.431183f, +0.58371f, -0.438873f, +0.577911f, -0.446472f, +0.572021f, -0.453979f, +0.56604f, -0.461426f, +0.559937f, -0.468811f, +0.553772f, -0.476105f, +0.547485f, -0.483307f, +0.541107f, -0.490417f, +0.534637f, -0.497467f, +0.528076f, -0.504425f, +0.521423f, -0.511292f, +0.514709f, -0.518066f, +0.507874f, -0.52478f, +0.500946f, -0.531372f, +0.493958f, -0.537872f, +0.486877f, -0.544312f, +0.479706f, -0.550629f, +0.472473f, -0.556854f, +0.465118f, -0.562988f, +0.457733f, -0.569031f, +0.450226f, -0.574982f, +0.442657f, -0.580841f, +0.435028f, -0.586578f, +0.427307f, -0.592224f, +0.419525f, -0.597748f, +0.411652f, -0.60321f, +0.403748f, -0.608521f, +0.395721f, -0.61377f, +0.387665f, -0.618896f, +0.379547f, -0.623901f, +0.371338f, -0.628845f, +0.363068f, -0.633636f, +0.354736f, -0.638336f, +0.346375f, -0.642914f, +0.337921f, -0.6474f, +0.329407f, -0.651764f, +0.320862f, -0.656036f, +0.312225f, -0.660156f, +0.303558f, -0.664215f, +0.294861f, -0.668121f, +0.286072f, -0.671906f, +0.277252f, -0.675598f, +0.268402f, -0.679169f, +0.259491f, -0.682648f, +0.250519f, -0.685974f, +0.241516f, -0.689178f, +0.232483f, -0.692291f, +0.223389f, -0.695282f, +0.214264f, -0.698151f, +0.205109f, -0.700897f, +0.195923f, -0.703522f, +0.186707f, -0.706024f, +0.17746f, -0.708405f, +0.168152f, -0.710663f, +0.158844f, -0.712799f, +0.149506f, -0.714813f, +0.140137f, -0.716705f, +0.130737f, -0.718475f, +0.121307f, -0.720123f, +0.111877f, -0.72168f, +0.102417f, -0.723053f, +0.0929565f, -0.724335f, +0.0834656f, -0.725494f, +0.0739441f, -0.726532f, +0.0644531f, -0.727448f, +0.0549011f, -0.72821f, +0.0453796f, -0.728882f, +0.0358276f, -0.729401f, +0.0262756f, -0.729797f, +0.0167236f, -0.730103f, +0.00717163f, -0.730255f +}; + +complex dct120_table_2[120] = { +0.999969f, 0.0f, +0.999908f, -0.013092f, +0.999664f, -0.0261841f, +0.999237f, -0.0392456f, +0.998627f, -0.0523376f, +0.997864f, -0.0653992f, +0.996918f, -0.0784607f, +0.995819f, -0.0914917f, +0.994507f, -0.104523f, +0.993073f, -0.117523f, +0.991455f, -0.130524f, +0.989655f, -0.143494f, +0.987701f, -0.156433f, +0.985565f, -0.169342f, +0.983246f, -0.18222f, +0.980774f, -0.195099f, +0.978149f, -0.207916f, +0.975342f, -0.220703f, +0.972382f, -0.233459f, +0.969238f, -0.246155f, +0.965912f, -0.25882f, +0.962463f, -0.271454f, +0.958832f, -0.284027f, +0.955017f, -0.296539f, +0.95105f, -0.309021f, +0.94693f, -0.321442f, +0.942627f, -0.333801f, +0.938202f, -0.34613f, +0.933594f, -0.358368f, +0.928802f, -0.370544f, +0.923889f, -0.38269f, +0.918793f, -0.394745f, +0.913544f, -0.406738f, +0.908142f, -0.418671f, +0.902588f, -0.430511f, +0.896881f, -0.442291f, +0.891022f, -0.453979f, +0.884979f, -0.465607f, +0.878815f, -0.477173f, +0.872498f, -0.488617f, +0.866028f, -0.5f, +0.859406f, -0.511292f, +0.852631f, -0.522491f, +0.845734f, -0.5336f, +0.838684f, -0.544647f, +0.831482f, -0.555573f, +0.824127f, -0.566406f, +0.81665f, -0.577148f, +0.809021f, -0.587799f, +0.801239f, -0.598328f, +0.793365f, -0.608765f, +0.785309f, -0.61908f, +0.777161f, -0.629333f, +0.768829f, -0.639435f, +0.760406f, -0.649445f, +0.751831f, -0.659332f, +0.743134f, -0.669128f, +0.734314f, -0.678802f, +0.725372f, -0.688354f, +0.716309f, -0.697784f, +0.707092f, -0.707092f, +0.697784f, -0.716309f, +0.688354f, -0.725372f, +0.678802f, -0.734314f, +0.669128f, -0.743134f, +0.659332f, -0.751831f, +0.649445f, -0.760406f, +0.639435f, -0.768829f, +0.629333f, -0.777161f, +0.61908f, -0.785309f, +0.608765f, -0.793365f, +0.598328f, -0.801239f, +0.587799f, -0.809021f, +0.577148f, -0.81665f, +0.566406f, -0.824127f, +0.555573f, -0.831482f, +0.544647f, -0.838684f, +0.5336f, -0.845734f, +0.522491f, -0.852631f, +0.511292f, -0.859406f, +0.5f, -0.866028f, +0.488617f, -0.872498f, +0.477173f, -0.878815f, +0.465607f, -0.884979f, +0.453979f, -0.891022f, +0.442291f, -0.896881f, +0.430511f, -0.902588f, +0.418671f, -0.908142f, +0.406738f, -0.913544f, +0.394745f, -0.918793f, +0.38269f, -0.923889f, +0.370544f, -0.928802f, +0.358368f, -0.933594f, +0.34613f, -0.938202f, +0.333801f, -0.942627f, +0.321442f, -0.94693f, +0.309021f, -0.95105f, +0.296539f, -0.955017f, +0.284027f, -0.958832f, +0.271454f, -0.962463f, +0.25882f, -0.965912f, +0.246155f, -0.969238f, +0.233459f, -0.972382f, +0.220703f, -0.975342f, +0.207916f, -0.978149f, +0.195099f, -0.980774f, +0.18222f, -0.983246f, +0.169342f, -0.985565f, +0.156433f, -0.987701f, +0.143494f, -0.989655f, +0.130524f, -0.991455f, +0.117523f, -0.993073f, +0.104523f, -0.994507f, +0.0914917f, -0.995819f, +0.0784607f, -0.996918f, +0.0653992f, -0.997864f, +0.0523376f, -0.998627f, +0.0392456f, -0.999237f, +0.0261841f, -0.999664f, +0.013092f, -0.999908f +}; + +complex dct480_table_1[480] = { +0.730286f, -0.000610352f, +0.730286f, -0.00299072f, +0.730255f, -0.00537109f, +0.730255f, -0.00778198f, +0.730225f, -0.0101624f, +0.730164f, -0.0125427f, +0.730133f, -0.0149231f, +0.730072f, -0.017334f, +0.730011f, -0.0197144f, +0.72995f, -0.0220947f, +0.729889f, -0.0245056f, +0.729797f, -0.026886f, +0.729706f, -0.0292664f, +0.729614f, -0.0316467f, +0.729492f, -0.0340576f, +0.72937f, -0.036438f, +0.729248f, -0.0388184f, +0.729126f, -0.0411987f, +0.728973f, -0.0435791f, +0.728851f, -0.0459595f, +0.728668f, -0.0483704f, +0.728516f, -0.0507507f, +0.728363f, -0.0531311f, +0.72818f, -0.0555115f, +0.727997f, -0.0578918f, +0.727783f, -0.0602722f, +0.7276f, -0.0626526f, +0.727386f, -0.065033f, +0.727173f, -0.0674133f, +0.726929f, -0.0697937f, +0.726715f, -0.0721741f, +0.726471f, -0.0745544f, +0.726227f, -0.0769348f, +0.725952f, -0.0793152f, +0.725708f, -0.0816956f, +0.725433f, -0.0840454f, +0.725159f, -0.0864258f, +0.724854f, -0.0888062f, +0.724579f, -0.0911865f, +0.724274f, -0.0935364f, +0.723969f, -0.0959167f, +0.723633f, -0.0982971f, +0.723328f, -0.100647f, +0.722992f, -0.103027f, +0.722656f, -0.105377f, +0.72229f, -0.107758f, +0.721924f, -0.110107f, +0.721558f, -0.112457f, +0.721191f, -0.114838f, +0.720825f, -0.117188f, +0.720428f, -0.119537f, +0.720032f, -0.121918f, +0.719635f, -0.124268f, +0.719238f, -0.126617f, +0.718811f, -0.128967f, +0.718384f, -0.131317f, +0.717957f, -0.133667f, +0.717499f, -0.136017f, +0.717072f, -0.138367f, +0.716614f, -0.140717f, +0.716125f, -0.143066f, +0.715668f, -0.145386f, +0.715179f, -0.147736f, +0.714691f, -0.150085f, +0.714203f, -0.152405f, +0.713715f, -0.154755f, +0.713196f, -0.157104f, +0.712677f, -0.159424f, +0.712158f, -0.161743f, +0.711609f, -0.164093f, +0.71106f, -0.166412f, +0.71051f, -0.168732f, +0.709961f, -0.171051f, +0.709412f, -0.17337f, +0.708832f, -0.17572f, +0.708252f, -0.17804f, +0.707672f, -0.180328f, +0.707062f, -0.182648f, +0.706482f, -0.184967f, +0.705872f, -0.187286f, +0.705261f, -0.189575f, +0.70462f, -0.191895f, +0.703979f, -0.194214f, +0.703339f, -0.196503f, +0.702698f, -0.198792f, +0.702057f, -0.201111f, +0.701385f, -0.2034f, +0.700714f, -0.205688f, +0.700043f, -0.207977f, +0.699371f, -0.210266f, +0.698669f, -0.212555f, +0.697968f, -0.214844f, +0.697266f, -0.217133f, +0.696533f, -0.219421f, +0.695831f, -0.22168f, +0.695099f, -0.223969f, +0.694366f, -0.226227f, +0.693604f, -0.228516f, +0.692871f, -0.230774f, +0.692108f, -0.233032f, +0.691345f, -0.235321f, +0.690552f, -0.237579f, +0.689789f, -0.239838f, +0.688995f, -0.242096f, +0.688202f, -0.244324f, +0.687408f, -0.246582f, +0.686584f, -0.24884f, +0.68576f, -0.251068f, +0.684937f, -0.253326f, +0.684113f, -0.255554f, +0.683258f, -0.257813f, +0.682434f, -0.26004f, +0.68158f, -0.262268f, +0.680695f, -0.264496f, +0.67984f, -0.266724f, +0.678955f, -0.268951f, +0.67807f, -0.271179f, +0.677185f, -0.273376f, +0.6763f, -0.275604f, +0.675385f, -0.277802f, +0.674469f, -0.280029f, +0.673553f, -0.282227f, +0.672607f, -0.284424f, +0.671692f, -0.286621f, +0.670746f, -0.288818f, +0.6698f, -0.291016f, +0.668854f, -0.293213f, +0.667877f, -0.29541f, +0.666901f, -0.297577f, +0.665924f, -0.299774f, +0.664948f, -0.301941f, +0.66394f, -0.304108f, +0.662964f, -0.306274f, +0.661957f, -0.308441f, +0.66095f, -0.310608f, +0.659912f, -0.312775f, +0.658875f, -0.314941f, +0.657867f, -0.317078f, +0.656799f, -0.319244f, +0.655762f, -0.321381f, +0.654694f, -0.323547f, +0.653656f, -0.325684f, +0.652588f, -0.32782f, +0.651489f, -0.329956f, +0.650421f, -0.332062f, +0.649323f, -0.334198f, +0.648224f, -0.336334f, +0.647125f, -0.33844f, +0.646027f, -0.340546f, +0.644897f, -0.342682f, +0.643768f, -0.344788f, +0.642639f, -0.346893f, +0.64151f, -0.348999f, +0.64035f, -0.351074f, +0.639191f, -0.35318f, +0.638031f, -0.355255f, +0.636871f, -0.357361f, +0.635712f, -0.359436f, +0.634521f, -0.361511f, +0.633331f, -0.363586f, +0.632141f, -0.365662f, +0.630951f, -0.367737f, +0.62973f, -0.369781f, +0.62854f, -0.371857f, +0.627319f, -0.373901f, +0.626068f, -0.375946f, +0.624847f, -0.377991f, +0.623596f, -0.380035f, +0.622345f, -0.38208f, +0.621094f, -0.384125f, +0.619843f, -0.386139f, +0.618591f, -0.388184f, +0.61731f, -0.390198f, +0.616028f, -0.392212f, +0.614746f, -0.394226f, +0.613434f, -0.39624f, +0.612152f, -0.398254f, +0.61084f, -0.400238f, +0.609528f, -0.402252f, +0.608215f, -0.404236f, +0.606873f, -0.406219f, +0.60556f, -0.408203f, +0.604218f, -0.410187f, +0.602875f, -0.41217f, +0.601501f, -0.414124f, +0.600159f, -0.416107f, +0.598785f, -0.41806f, +0.597412f, -0.420013f, +0.596039f, -0.421967f, +0.594666f, -0.42392f, +0.593262f, -0.425873f, +0.591858f, -0.427795f, +0.590454f, -0.429749f, +0.58905f, -0.431671f, +0.587646f, -0.433594f, +0.586212f, -0.435516f, +0.584778f, -0.437439f, +0.583344f, -0.439331f, +0.581909f, -0.441254f, +0.580475f, -0.443146f, +0.57901f, -0.445038f, +0.577545f, -0.44693f, +0.57608f, -0.448822f, +0.574615f, -0.450714f, +0.573151f, -0.452576f, +0.571655f, -0.454468f, +0.57016f, -0.456329f, +0.568665f, -0.458191f, +0.567169f, -0.460052f, +0.565643f, -0.461914f, +0.564148f, -0.463745f, +0.562622f, -0.465607f, +0.561096f, -0.467438f, +0.55957f, -0.469269f, +0.558014f, -0.4711f, +0.556488f, -0.472931f, +0.554932f, -0.474731f, +0.553375f, -0.476563f, +0.551819f, -0.478363f, +0.550232f, -0.480164f, +0.548676f, -0.481964f, +0.547089f, -0.483765f, +0.545502f, -0.485535f, +0.543915f, -0.487335f, +0.542297f, -0.489105f, +0.54071f, -0.490875f, +0.539093f, -0.492645f, +0.537476f, -0.494415f, +0.535858f, -0.496155f, +0.534241f, -0.497894f, +0.532593f, -0.499664f, +0.530975f, -0.501404f, +0.529327f, -0.503143f, +0.527679f, -0.504852f, +0.526001f, -0.506592f, +0.524353f, -0.508301f, +0.522675f, -0.51001f, +0.521027f, -0.511719f, +0.519348f, -0.513428f, +0.51767f, -0.515106f, +0.515961f, -0.516815f, +0.514282f, -0.518494f, +0.512573f, -0.520172f, +0.510864f, -0.521851f, +0.509155f, -0.523529f, +0.507446f, -0.525177f, +0.505707f, -0.526855f, +0.503998f, -0.528503f, +0.502258f, -0.530151f, +0.500519f, -0.531769f, +0.498779f, -0.533417f, +0.49704f, -0.535034f, +0.49527f, -0.536682f, +0.49353f, -0.5383f, +0.49176f, -0.539886f, +0.48999f, -0.541504f, +0.48822f, -0.543121f, +0.48642f, -0.544708f, +0.48465f, -0.546295f, +0.482849f, -0.547882f, +0.481049f, -0.549438f, +0.479248f, -0.551025f, +0.477448f, -0.552582f, +0.475647f, -0.554138f, +0.473816f, -0.555695f, +0.472015f, -0.557251f, +0.470184f, -0.558777f, +0.468353f, -0.560333f, +0.466522f, -0.561859f, +0.464661f, -0.563385f, +0.46283f, -0.564911f, +0.460968f, -0.566406f, +0.459106f, -0.567902f, +0.457245f, -0.569427f, +0.455383f, -0.570892f, +0.453522f, -0.572388f, +0.45166f, -0.573883f, +0.449768f, -0.575348f, +0.447876f, -0.576813f, +0.445984f, -0.578278f, +0.444092f, -0.579742f, +0.4422f, -0.581177f, +0.440277f, -0.582642f, +0.438385f, -0.584076f, +0.436462f, -0.58551f, +0.43454f, -0.586914f, +0.432617f, -0.588348f, +0.430695f, -0.589752f, +0.428772f, -0.591156f, +0.426819f, -0.59256f, +0.424896f, -0.593964f, +0.422943f, -0.595337f, +0.42099f, -0.596741f, +0.419037f, -0.598114f, +0.417084f, -0.599457f, +0.4151f, -0.60083f, +0.413147f, -0.602173f, +0.411163f, -0.603546f, +0.40921f, -0.604889f, +0.407227f, -0.606201f, +0.405243f, -0.607544f, +0.403229f, -0.608856f, +0.401245f, -0.610168f, +0.399231f, -0.611481f, +0.397247f, -0.612793f, +0.395233f, -0.614105f, +0.393219f, -0.615387f, +0.391205f, -0.616669f, +0.389191f, -0.61795f, +0.387177f, -0.619202f, +0.385132f, -0.620483f, +0.383087f, -0.621735f, +0.381073f, -0.622986f, +0.379028f, -0.624237f, +0.376984f, -0.625458f, +0.374939f, -0.626709f, +0.372864f, -0.62793f, +0.370819f, -0.62912f, +0.368744f, -0.630341f, +0.366699f, -0.631561f, +0.364624f, -0.632751f, +0.362549f, -0.633942f, +0.360474f, -0.635132f, +0.358398f, -0.636292f, +0.356323f, -0.637451f, +0.354218f, -0.638611f, +0.352142f, -0.639771f, +0.350037f, -0.64093f, +0.347931f, -0.642059f, +0.345825f, -0.643219f, +0.343719f, -0.644348f, +0.341614f, -0.645447f, +0.339508f, -0.646576f, +0.337372f, -0.647675f, +0.335266f, -0.648773f, +0.33313f, -0.649872f, +0.331024f, -0.65097f, +0.328888f, -0.652039f, +0.326752f, -0.653107f, +0.324615f, -0.654175f, +0.322449f, -0.655243f, +0.320313f, -0.656281f, +0.318176f, -0.657349f, +0.31601f, -0.658386f, +0.313843f, -0.659393f, +0.311707f, -0.660431f, +0.30954f, -0.661438f, +0.307373f, -0.662445f, +0.305206f, -0.663452f, +0.30304f, -0.664459f, +0.300842f, -0.665436f, +0.298676f, -0.666412f, +0.296478f, -0.667389f, +0.294312f, -0.668365f, +0.292114f, -0.669312f, +0.289917f, -0.670258f, +0.28772f, -0.671204f, +0.285522f, -0.67215f, +0.283325f, -0.673096f, +0.281128f, -0.674011f, +0.278931f, -0.674927f, +0.276703f, -0.675842f, +0.274506f, -0.676727f, +0.272278f, -0.677643f, +0.27005f, -0.678528f, +0.267822f, -0.679413f, +0.265625f, -0.680267f, +0.263397f, -0.681122f, +0.261139f, -0.682007f, +0.258911f, -0.682831f, +0.256683f, -0.683685f, +0.254456f, -0.68454f, +0.252197f, -0.685364f, +0.249969f, -0.686188f, +0.247711f, -0.686981f, +0.245453f, -0.687805f, +0.243225f, -0.688599f, +0.240967f, -0.689392f, +0.238708f, -0.690186f, +0.23645f, -0.690948f, +0.234192f, -0.691711f, +0.231903f, -0.692474f, +0.229645f, -0.693237f, +0.227386f, -0.694f, +0.225098f, -0.694733f, +0.222839f, -0.695465f, +0.220551f, -0.696198f, +0.218262f, -0.696899f, +0.216003f, -0.697601f, +0.213715f, -0.698303f, +0.211426f, -0.699005f, +0.209137f, -0.699707f, +0.206848f, -0.700378f, +0.204559f, -0.70105f, +0.20224f, -0.701721f, +0.199951f, -0.702393f, +0.197662f, -0.703033f, +0.195343f, -0.703674f, +0.193054f, -0.704315f, +0.190735f, -0.704926f, +0.188446f, -0.705566f, +0.186127f, -0.706177f, +0.183807f, -0.706787f, +0.181488f, -0.707367f, +0.179169f, -0.707977f, +0.17688f, -0.708557f, +0.174561f, -0.709106f, +0.172211f, -0.709686f, +0.169891f, -0.710236f, +0.167572f, -0.710785f, +0.165253f, -0.711334f, +0.162933f, -0.711884f, +0.160583f, -0.712402f, +0.158264f, -0.712921f, +0.155914f, -0.71344f, +0.153595f, -0.713959f, +0.151245f, -0.714447f, +0.148926f, -0.714935f, +0.146576f, -0.715424f, +0.144226f, -0.715912f, +0.141876f, -0.71637f, +0.139526f, -0.716827f, +0.137207f, -0.717285f, +0.134857f, -0.717743f, +0.132507f, -0.71817f, +0.130157f, -0.718597f, +0.127808f, -0.719025f, +0.125427f, -0.719421f, +0.123077f, -0.719849f, +0.120728f, -0.720245f, +0.118378f, -0.720642f, +0.115997f, -0.721008f, +0.113647f, -0.721375f, +0.111298f, -0.721741f, +0.108917f, -0.722107f, +0.106567f, -0.722473f, +0.104187f, -0.722809f, +0.101837f, -0.723145f, +0.0994568f, -0.72348f, +0.0971069f, -0.723816f, +0.0947266f, -0.724121f, +0.0923462f, -0.724426f, +0.0899963f, -0.724731f, +0.087616f, -0.725006f, +0.0852356f, -0.725281f, +0.0828552f, -0.725555f, +0.0805054f, -0.72583f, +0.078125f, -0.726105f, +0.0757446f, -0.726349f, +0.0733643f, -0.726593f, +0.0709839f, -0.726837f, +0.0686035f, -0.727051f, +0.0662231f, -0.727264f, +0.0638428f, -0.727478f, +0.0614624f, -0.727692f, +0.059082f, -0.727905f, +0.0567017f, -0.728088f, +0.0543213f, -0.728271f, +0.0519409f, -0.728424f, +0.0495605f, -0.728607f, +0.0471802f, -0.72876f, +0.0447693f, -0.728912f, +0.0423889f, -0.729065f, +0.0400085f, -0.729187f, +0.0376282f, -0.729309f, +0.0352478f, -0.729431f, +0.0328369f, -0.729553f, +0.0304565f, -0.729645f, +0.0280762f, -0.729736f, +0.0256958f, -0.729828f, +0.0232849f, -0.729919f, +0.0209045f, -0.72998f, +0.0185242f, -0.730042f, +0.0161438f, -0.730103f, +0.0137329f, -0.730164f, +0.0113525f, -0.730194f, +0.00897217f, -0.730225f, +0.00656128f, -0.730255f, +0.00418091f, -0.730286f, +0.00180054f, -0.730286f +}; + +complex dct480_table_2[480] = { +0.999969f, 0.0f, +0.999969f, -0.00326538f, +0.999969f, -0.00653076f, +0.999939f, -0.00982666f, +0.999908f, -0.013092f, +0.999878f, -0.0163574f, +0.999817f, -0.0196228f, +0.999725f, -0.0229187f, +0.999664f, -0.0261841f, +0.999573f, -0.0294495f, +0.999451f, -0.0327148f, +0.999359f, -0.0359802f, +0.999237f, -0.0392456f, +0.999084f, -0.0425415f, +0.998962f, -0.0458069f, +0.99881f, -0.0490723f, +0.998627f, -0.0523376f, +0.998444f, -0.055603f, +0.99826f, -0.0588684f, +0.998077f, -0.0621338f, +0.997864f, -0.0653992f, +0.99765f, -0.0686646f, +0.997406f, -0.0719299f, +0.997162f, -0.0751953f, +0.996918f, -0.0784607f, +0.996643f, -0.0817261f, +0.996368f, -0.0849915f, +0.996094f, -0.0882568f, +0.995819f, -0.0914917f, +0.995514f, -0.0947571f, +0.995178f, -0.0980225f, +0.994873f, -0.101288f, +0.994507f, -0.104523f, +0.994171f, -0.107788f, +0.993805f, -0.111023f, +0.993439f, -0.114288f, +0.993073f, -0.117523f, +0.992676f, -0.120789f, +0.992279f, -0.124023f, +0.991852f, -0.127289f, +0.991455f, -0.130524f, +0.990997f, -0.133759f, +0.99057f, -0.137024f, +0.990112f, -0.140259f, +0.989655f, -0.143494f, +0.989166f, -0.146729f, +0.988678f, -0.149963f, +0.98819f, -0.153198f, +0.987701f, -0.156433f, +0.987183f, -0.159668f, +0.986633f, -0.162903f, +0.986115f, -0.166138f, +0.985565f, -0.169342f, +0.984985f, -0.172577f, +0.984436f, -0.175781f, +0.983856f, -0.179016f, +0.983246f, -0.18222f, +0.982666f, -0.185455f, +0.982056f, -0.18866f, +0.981415f, -0.191895f, +0.980774f, -0.195099f, +0.980133f, -0.198303f, +0.979492f, -0.201508f, +0.978821f, -0.204712f, +0.978149f, -0.207916f, +0.977448f, -0.211121f, +0.976776f, -0.214294f, +0.976074f, -0.217499f, +0.975342f, -0.220703f, +0.974609f, -0.223877f, +0.973877f, -0.227081f, +0.973114f, -0.230255f, +0.972382f, -0.233459f, +0.971588f, -0.236633f, +0.970825f, -0.239807f, +0.970032f, -0.242981f, +0.969238f, -0.246155f, +0.968414f, -0.249329f, +0.96759f, -0.252502f, +0.966766f, -0.255646f, +0.965912f, -0.25882f, +0.965088f, -0.261993f, +0.964203f, -0.265137f, +0.963348f, -0.26828f, +0.962463f, -0.271454f, +0.961548f, -0.274597f, +0.960663f, -0.27774f, +0.959747f, -0.280884f, +0.958832f, -0.284027f, +0.957886f, -0.28714f, +0.95694f, -0.290283f, +0.955994f, -0.293427f, +0.955017f, -0.296539f, +0.954041f, -0.299652f, +0.953064f, -0.302795f, +0.952057f, -0.305908f, +0.95105f, -0.309021f, +0.950043f, -0.312134f, +0.949005f, -0.315247f, +0.947968f, -0.318329f, +0.94693f, -0.321442f, +0.945862f, -0.324524f, +0.944794f, -0.327637f, +0.943726f, -0.330719f, +0.942627f, -0.333801f, +0.941559f, -0.336884f, +0.94043f, -0.339966f, +0.939331f, -0.343048f, +0.938202f, -0.34613f, +0.937042f, -0.349182f, +0.935913f, -0.352264f, +0.934753f, -0.355316f, +0.933594f, -0.358368f, +0.932404f, -0.36142f, +0.931213f, -0.364471f, +0.930023f, -0.367523f, +0.928802f, -0.370544f, +0.927582f, -0.373596f, +0.926361f, -0.376617f, +0.92514f, -0.379669f, +0.923889f, -0.38269f, +0.922607f, -0.385712f, +0.921356f, -0.388733f, +0.920074f, -0.391724f, +0.918793f, -0.394745f, +0.91748f, -0.397736f, +0.916199f, -0.400757f, +0.914886f, -0.403748f, +0.913544f, -0.406738f, +0.912201f, -0.409729f, +0.910858f, -0.41272f, +0.909515f, -0.41568f, +0.908142f, -0.418671f, +0.906769f, -0.421631f, +0.905396f, -0.424591f, +0.903992f, -0.427551f, +0.902588f, -0.430511f, +0.901184f, -0.433472f, +0.89975f, -0.436401f, +0.898315f, -0.439362f, +0.896881f, -0.442291f, +0.895416f, -0.445221f, +0.893951f, -0.448151f, +0.892487f, -0.45108f, +0.891022f, -0.453979f, +0.889526f, -0.456909f, +0.888031f, -0.459808f, +0.886505f, -0.462708f, +0.884979f, -0.465607f, +0.883453f, -0.468506f, +0.881927f, -0.471405f, +0.880371f, -0.474274f, +0.878815f, -0.477173f, +0.877258f, -0.480042f, +0.875671f, -0.48291f, +0.874084f, -0.485748f, +0.872498f, -0.488617f, +0.87088f, -0.491486f, +0.869293f, -0.494324f, +0.867645f, -0.497162f, +0.866028f, -0.5f, +0.86438f, -0.502838f, +0.862732f, -0.505646f, +0.861084f, -0.508484f, +0.859406f, -0.511292f, +0.857727f, -0.514099f, +0.856049f, -0.516907f, +0.85434f, -0.519714f, +0.852631f, -0.522491f, +0.850922f, -0.525299f, +0.849213f, -0.528076f, +0.847473f, -0.530853f, +0.845734f, -0.5336f, +0.843964f, -0.536377f, +0.842224f, -0.539124f, +0.840454f, -0.541901f, +0.838684f, -0.544647f, +0.836884f, -0.547394f, +0.835083f, -0.55011f, +0.833282f, -0.552856f, +0.831482f, -0.555573f, +0.829651f, -0.558289f, +0.82782f, -0.561005f, +0.825989f, -0.563721f, +0.824127f, -0.566406f, +0.822266f, -0.569092f, +0.820404f, -0.571777f, +0.818512f, -0.574463f, +0.81665f, -0.577148f, +0.814758f, -0.579803f, +0.812836f, -0.582489f, +0.810944f, -0.585144f, +0.809021f, -0.587799f, +0.807098f, -0.590424f, +0.805145f, -0.593079f, +0.803223f, -0.595703f, +0.801239f, -0.598328f, +0.799286f, -0.600952f, +0.797333f, -0.603546f, +0.795349f, -0.606171f, +0.793365f, -0.608765f, +0.791351f, -0.611359f, +0.789337f, -0.613953f, +0.787354f, -0.616516f, +0.785309f, -0.61908f, +0.783295f, -0.621674f, +0.78125f, -0.624207f, +0.779205f, -0.62677f, +0.777161f, -0.629333f, +0.775085f, -0.631866f, +0.77301f, -0.634399f, +0.770935f, -0.636932f, +0.768829f, -0.639435f, +0.766754f, -0.641937f, +0.764648f, -0.64447f, +0.762512f, -0.646942f, +0.760406f, -0.649445f, +0.75827f, -0.651947f, +0.756134f, -0.654419f, +0.753998f, -0.656891f, +0.751831f, -0.659332f, +0.749664f, -0.661804f, +0.747498f, -0.664246f, +0.745331f, -0.666687f, +0.743134f, -0.669128f, +0.740936f, -0.67157f, +0.738739f, -0.673981f, +0.736542f, -0.676392f, +0.734314f, -0.678802f, +0.732086f, -0.681213f, +0.729858f, -0.683594f, +0.727631f, -0.685974f, +0.725372f, -0.688354f, +0.723114f, -0.690735f, +0.720856f, -0.693085f, +0.718567f, -0.695435f, +0.716309f, -0.697784f, +0.71402f, -0.700134f, +0.711731f, -0.702454f, +0.709412f, -0.704803f, +0.707092f, -0.707092f, +0.704803f, -0.709412f, +0.702454f, -0.711731f, +0.700134f, -0.71402f, +0.697784f, -0.716309f, +0.695435f, -0.718567f, +0.693085f, -0.720856f, +0.690735f, -0.723114f, +0.688354f, -0.725372f, +0.685974f, -0.727631f, +0.683594f, -0.729858f, +0.681213f, -0.732086f, +0.678802f, -0.734314f, +0.676392f, -0.736542f, +0.673981f, -0.738739f, +0.67157f, -0.740936f, +0.669128f, -0.743134f, +0.666687f, -0.745331f, +0.664246f, -0.747498f, +0.661804f, -0.749664f, +0.659332f, -0.751831f, +0.656891f, -0.753998f, +0.654419f, -0.756134f, +0.651947f, -0.75827f, +0.649445f, -0.760406f, +0.646942f, -0.762512f, +0.64447f, -0.764648f, +0.641937f, -0.766754f, +0.639435f, -0.768829f, +0.636932f, -0.770935f, +0.634399f, -0.77301f, +0.631866f, -0.775085f, +0.629333f, -0.777161f, +0.62677f, -0.779205f, +0.624207f, -0.78125f, +0.621674f, -0.783295f, +0.61908f, -0.785309f, +0.616516f, -0.787354f, +0.613953f, -0.789337f, +0.611359f, -0.791351f, +0.608765f, -0.793365f, +0.606171f, -0.795349f, +0.603546f, -0.797333f, +0.600952f, -0.799286f, +0.598328f, -0.801239f, +0.595703f, -0.803223f, +0.593079f, -0.805145f, +0.590424f, -0.807098f, +0.587799f, -0.809021f, +0.585144f, -0.810944f, +0.582489f, -0.812836f, +0.579803f, -0.814758f, +0.577148f, -0.81665f, +0.574463f, -0.818512f, +0.571777f, -0.820404f, +0.569092f, -0.822266f, +0.566406f, -0.824127f, +0.563721f, -0.825989f, +0.561005f, -0.82782f, +0.558289f, -0.829651f, +0.555573f, -0.831482f, +0.552856f, -0.833282f, +0.55011f, -0.835083f, +0.547394f, -0.836884f, +0.544647f, -0.838684f, +0.541901f, -0.840454f, +0.539124f, -0.842224f, +0.536377f, -0.843964f, +0.5336f, -0.845734f, +0.530853f, -0.847473f, +0.528076f, -0.849213f, +0.525299f, -0.850922f, +0.522491f, -0.852631f, +0.519714f, -0.85434f, +0.516907f, -0.856049f, +0.514099f, -0.857727f, +0.511292f, -0.859406f, +0.508484f, -0.861084f, +0.505646f, -0.862732f, +0.502838f, -0.86438f, +0.5f, -0.866028f, +0.497162f, -0.867645f, +0.494324f, -0.869293f, +0.491486f, -0.87088f, +0.488617f, -0.872498f, +0.485748f, -0.874084f, +0.48291f, -0.875671f, +0.480042f, -0.877258f, +0.477173f, -0.878815f, +0.474274f, -0.880371f, +0.471405f, -0.881927f, +0.468506f, -0.883453f, +0.465607f, -0.884979f, +0.462708f, -0.886505f, +0.459808f, -0.888031f, +0.456909f, -0.889526f, +0.453979f, -0.891022f, +0.45108f, -0.892487f, +0.448151f, -0.893951f, +0.445221f, -0.895416f, +0.442291f, -0.896881f, +0.439362f, -0.898315f, +0.436401f, -0.89975f, +0.433472f, -0.901184f, +0.430511f, -0.902588f, +0.427551f, -0.903992f, +0.424591f, -0.905396f, +0.421631f, -0.906769f, +0.418671f, -0.908142f, +0.41568f, -0.909515f, +0.41272f, -0.910858f, +0.409729f, -0.912201f, +0.406738f, -0.913544f, +0.403748f, -0.914886f, +0.400757f, -0.916199f, +0.397736f, -0.91748f, +0.394745f, -0.918793f, +0.391724f, -0.920074f, +0.388733f, -0.921356f, +0.385712f, -0.922607f, +0.38269f, -0.923889f, +0.379669f, -0.92514f, +0.376617f, -0.926361f, +0.373596f, -0.927582f, +0.370544f, -0.928802f, +0.367523f, -0.930023f, +0.364471f, -0.931213f, +0.36142f, -0.932404f, +0.358368f, -0.933594f, +0.355316f, -0.934753f, +0.352264f, -0.935913f, +0.349182f, -0.937042f, +0.34613f, -0.938202f, +0.343048f, -0.939331f, +0.339966f, -0.94043f, +0.336884f, -0.941559f, +0.333801f, -0.942627f, +0.330719f, -0.943726f, +0.327637f, -0.944794f, +0.324524f, -0.945862f, +0.321442f, -0.94693f, +0.318329f, -0.947968f, +0.315247f, -0.949005f, +0.312134f, -0.950043f, +0.309021f, -0.95105f, +0.305908f, -0.952057f, +0.302795f, -0.953064f, +0.299652f, -0.954041f, +0.296539f, -0.955017f, +0.293427f, -0.955994f, +0.290283f, -0.95694f, +0.28714f, -0.957886f, +0.284027f, -0.958832f, +0.280884f, -0.959747f, +0.27774f, -0.960663f, +0.274597f, -0.961548f, +0.271454f, -0.962463f, +0.26828f, -0.963348f, +0.265137f, -0.964203f, +0.261993f, -0.965088f, +0.25882f, -0.965912f, +0.255646f, -0.966766f, +0.252502f, -0.96759f, +0.249329f, -0.968414f, +0.246155f, -0.969238f, +0.242981f, -0.970032f, +0.239807f, -0.970825f, +0.236633f, -0.971588f, +0.233459f, -0.972382f, +0.230255f, -0.973114f, +0.227081f, -0.973877f, +0.223877f, -0.974609f, +0.220703f, -0.975342f, +0.217499f, -0.976074f, +0.214294f, -0.976776f, +0.211121f, -0.977448f, +0.207916f, -0.978149f, +0.204712f, -0.978821f, +0.201508f, -0.979492f, +0.198303f, -0.980133f, +0.195099f, -0.980774f, +0.191895f, -0.981415f, +0.18866f, -0.982056f, +0.185455f, -0.982666f, +0.18222f, -0.983246f, +0.179016f, -0.983856f, +0.175781f, -0.984436f, +0.172577f, -0.984985f, +0.169342f, -0.985565f, +0.166138f, -0.986115f, +0.162903f, -0.986633f, +0.159668f, -0.987183f, +0.156433f, -0.987701f, +0.153198f, -0.98819f, +0.149963f, -0.988678f, +0.146729f, -0.989166f, +0.143494f, -0.989655f, +0.140259f, -0.990112f, +0.137024f, -0.99057f, +0.133759f, -0.990997f, +0.130524f, -0.991455f, +0.127289f, -0.991852f, +0.124023f, -0.992279f, +0.120789f, -0.992676f, +0.117523f, -0.993073f, +0.114288f, -0.993439f, +0.111023f, -0.993805f, +0.107788f, -0.994171f, +0.104523f, -0.994507f, +0.101288f, -0.994873f, +0.0980225f, -0.995178f, +0.0947571f, -0.995514f, +0.0914917f, -0.995819f, +0.0882568f, -0.996094f, +0.0849915f, -0.996368f, +0.0817261f, -0.996643f, +0.0784607f, -0.996918f, +0.0751953f, -0.997162f, +0.0719299f, -0.997406f, +0.0686646f, -0.99765f, +0.0653992f, -0.997864f, +0.0621338f, -0.998077f, +0.0588684f, -0.99826f, +0.055603f, -0.998444f, +0.0523376f, -0.998627f, +0.0490723f, -0.99881f, +0.0458069f, -0.998962f, +0.0425415f, -0.999084f, +0.0392456f, -0.999237f, +0.0359802f, -0.999359f, +0.0327148f, -0.999451f, +0.0294495f, -0.999573f, +0.0261841f, -0.999664f, +0.0229187f, -0.999725f, +0.0196228f, -0.999817f, +0.0163574f, -0.999878f, +0.013092f, -0.999908f, +0.00982666f, -0.999939f, +0.00653076f, -0.999969f, +0.00326538f, -1.0f, +}; + +short RV[10] = { +0, 1, 4, 8, 16, 32, 64, 128, 256, 512 +}; + +short FacLVQ2Qv[10] = { +0, 0, 11, 10, 9, 8, 7, 6, 5, 4 +}; + +short FacLVQ2Mask[10] = { +0, 0, 2047, 1023, 511, 255, 127, 63, 31, 15 +}; + +short FacLVQ2HalfQv[10] = { +0, 0, 1024, 512, 256, 128, 64, 32, 16, 8 +}; + +short huffsizn[32] = { +7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 4, 4, 3, 3, +3, 3, 4, 4, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7 +}; + +short huffoffset[6] = { +0, 0, 0, 4, 12, 28 +}; + +short huffsizc[60] = { +1, 3, 3, 2, +2, 2, 4, 5, 5, 4, 4, 2, +2, 3, 4, 4, 5, 5, 5, 6, 6, 5, 5, 5, 5, 4, 4, 3, +2, 3, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 4, 3 +}; + +short dicnlg2[40] = { +34, 33, 32, 31, 30, 29, 28, 27, 26, 25, +24, 23, 22, 21, 20, 19, 18, 17, 16, 15, +14, 13, 12, 11, 10, 9, 8, 7, 6, 5, + 4, 3, 2, 1, 0, -1, -2, -3, -4, -5 +}; + +/*** Table for quantization of MLT coefficients ***/ +short sfmsize[44] = { + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, +16, 16, 16, 16, 16, 16, 16, 16, +24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, +32, 32, 32, 32, 32, 32, 32, 32 +}; + +short sfm_start[44] = { + 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, + 88, 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, + 224, 240, 256, 280, 304, 328, 352, 376, 400, 424, 448, + 472, 496, 520, 544, 576, 608, 640, 672, 704, 736, 768 +}; + +short sfm_end[44] = { + 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, + 96, 104, 112, 120, 128, 144, 160, 176, 192, 208, 224, + 240, 256, 280, 304, 328, 352, 376, 400, 424, 448, 472, + 496, 520, 544, 576, 608, 640, 672, 704, 736, 768, 800 +}; + +short sfm_width[20] = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 8}; +short a[20] = {8, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5, 7, 11}; diff --git a/Frameworks/g719/g719/reference_code/common/complxop.c b/Frameworks/g719/g719/reference_code/common/complxop.c new file mode 100755 index 000000000..000b75550 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/common/complxop.c @@ -0,0 +1,73 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "complxop.h" + +/*--------------------------------------------------------------------------*/ +/* Function cadd */ +/* ~~~~~~~~~~~~~~ */ +/* */ +/* Add complex variables */ +/*--------------------------------------------------------------------------*/ +/* complex var1 (i) variable 1 */ +/* complex var2 (i) variable 2 */ +/* complex *res (o) result of addition */ +/*--------------------------------------------------------------------------*/ +void cadd(complex var1, complex var2, complex *res) +{ + res->r = var1.r + var2.r; + res->i = var1.i + var2.i; +} + +/*--------------------------------------------------------------------------*/ +/* Function csub */ +/* ~~~~~~~~~~~~~~ */ +/* */ +/* Subtract complex variables */ +/*--------------------------------------------------------------------------*/ +/* complex var1 (i) variable 1 */ +/* complex var2 (i) variable 2 */ +/* complex *res (o) result of subtraction */ +/*--------------------------------------------------------------------------*/ +void csub(complex var1, complex var2, complex *res) +{ + res->r = var1.r - var2.r; + res->i = var1.i - var2.i; +} + +/*--------------------------------------------------------------------------*/ +/* Function cmpys */ +/* ~~~~~~~~~~~~~~~ */ +/* */ +/* Multiply complex variable with a scalar */ +/*--------------------------------------------------------------------------*/ +/* complex var1 (i) variable 1 */ +/* float var2 (i) variable 2 */ +/* complex *res (o) result */ +/*--------------------------------------------------------------------------*/ +void cmpys(complex var1, float var2, complex *res) +{ + res->r = var1.r * var2; + res->i = var1.i * var2; +} + +/*--------------------------------------------------------------------------*/ +/* Function cmpyj */ +/* ~~~~~~~~~~~~~~~ */ +/* */ +/* Find orthogonal complex variable */ +/*--------------------------------------------------------------------------*/ +/* complex *v1 (i/o) variable */ +/*--------------------------------------------------------------------------*/ +void cmpyj(complex* v1) +{ + float a; + + a = v1->r; + v1->r = -v1->i; + v1->i = a; +} + diff --git a/Frameworks/g719/g719/reference_code/common/dct.c b/Frameworks/g719/g719/reference_code/common/dct.c new file mode 100755 index 000000000..bb3fbff77 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/common/dct.c @@ -0,0 +1,403 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "cnst.h" +#include "complxop.h" +#include "rom.h" + +/*--------------------------------------------------------------------------*/ +/* Function wfft120 */ +/* ~~~~~~~~~~~~~~~~~ */ +/* */ +/* Winograd 120 point FFT */ +/*--------------------------------------------------------------------------*/ +/* complex *xi (i/o) input and output of the FFT */ +/*--------------------------------------------------------------------------*/ +void wfft120(complex *xi) +{ + short ind0, n3, n5; + float t0r, t1r, t2r, t3r, t4r, t5r, t6r, t7r, q1r, x1r, x5r; + float t0i, t1i, t2i, t3i, t4i, t5i, t6i, t7i, q1i, x1i, x5i; + float *ps; + complex x[144]; + complex *p0, *p1, *p2, *p3, *p4, *p5, *p6, *p7; + complex *pi0, *pi1, *pi2, *pi3, *pi4, *pi5, *pi6, *pi7; + + p0 = x; + for (ind0 = 0; ind0 < 120; ind0 += 8) + { + pi0 = xi + indxPre[ind0+0]; + pi1 = xi + indxPre[ind0+1]; + pi2 = xi + indxPre[ind0+2]; + pi3 = xi + indxPre[ind0+3]; + pi4 = xi + indxPre[ind0+4]; + pi5 = xi + indxPre[ind0+5]; + pi6 = xi + indxPre[ind0+6]; + pi7 = xi + indxPre[ind0+7]; + + t0r = pi0->r + pi4->r; + t0i = pi0->i + pi4->i; + t1r = pi1->r + pi5->r; + t1i = pi1->i + pi5->i; + t2r = pi2->r + pi6->r; + t2i = pi2->i + pi6->i; + t3r = pi3->r + pi7->r; + t3i = pi3->i + pi7->i; + t5r = pi1->r - pi5->r; + t5i = pi1->i - pi5->i; + t7r = pi3->r - pi7->r; + t7i = pi3->i - pi7->i; + + p0->r = t0r + t2r; + p0->i = t0i + t2i; + p0++; + p0->r = t1r + t3r; + p0->i = t1i + t3i; + p0++; + p0->r = t0r - t2r; + p0->i = t0i - t2i; + p0++; + p0->r = t1r - t3r; + p0->i = t1i - t3i; + p0++; + p0->r = pi0->r - pi4->r; + p0->i = pi0->i - pi4->i; + p0++; + p0->r = t5r + t7r; + p0->i = t5i + t7i; + p0++; + p0->r = pi2->r - pi6->r; + p0->i = pi2->i - pi6->i; + p0++; + p0->r = t5r - t7r; + p0->i = t5i - t7i; + p0++; + } + + for (n5 = 0; n5 < 120; n5 += 24) + { + for (ind0 = n5; ind0 < (n5+8); ind0++) + { + p0 = x + ind0; + p1 = x + ind0 + 8; + p2 = x + ind0 + 16; + + x1r = p1->r; + x1i = p1->i; + p1->r = x1r + p2->r; + p1->i = x1i + p2->i; + p2->r = x1r - p2->r; + p2->i = x1i - p2->i; + cadd(*p0, *p1, p0); + } + } + + for (n3 = 0; n3 < 24; n3 += 8) + { + for (ind0 = n3; ind0 < (n3+8); ind0++) + { + p0 = x + ind0; + p1 = x + ind0 + 24; + p2 = x + ind0 + 48; + p3 = x + ind0 + 72; + p4 = x + ind0 + 96; + p5 = x + ind0 + 120; + ps = fft120cnst + ind0; + + t3r = p3->r + p2->r; + t3i = p3->i + p2->i; + t2r = p3->r - p2->r; + t2i = p3->i - p2->i; + t1r = p1->r + p4->r; + t1i = p1->i + p4->i; + csub(*p1, *p4, p2); + + p1->r = t1r + t3r; + p1->i = t1i + t3i; + p3->r = t1r - t3r; + p3->i = t1i - t3i; + + x5r = p2->r + t2r; + x5i = p2->i + t2i; + cadd(*p0, *p1, p0); + + cmpys(*p0, *ps, p0); + ps += 24; + cmpys(*p1, *ps, p1); + ps += 24; + cmpys(*p2, *ps, p2); + ps += 24; + cmpys(*p3, *ps, p3); + ps += 24; + p4->r = t2r * *ps; + p4->i = t2i * *ps; + ps += 24; + p5->r = x5r * *ps; + p5->i = x5i * *ps; + } + } + + for (n3 = 0; n3 < 24; n3 += 8) + { + for (ind0 = n3; ind0 < (n3+8); ind0++) + { + p0 = x + ind0; + p1 = x + ind0 + 24; + p2 = x + ind0 + 48; + p3 = x + ind0 + 72; + p4 = x + ind0 + 96; + p5 = x + ind0 + 120; + + cmpyj(p2); + cmpyj(p4); + cmpyj(p5); + + q1r = p0->r + p1->r; + q1i = p0->i + p1->i; + + t1r = q1r + p3->r; + t1i = q1i + p3->i; + t4r = p2->r + p5->r; + t4i = p2->i + p5->i; + t3r = q1r - p3->r; + t3i = q1i - p3->i; + t2r = p4->r + p5->r; + t2i = p4->i + p5->i; + + p1->r = t1r + t4r; + p1->i = t1i + t4i; + p4->r = t1r - t4r; + p4->i = t1i - t4i; + p3->r = t3r + t2r; + p3->i = t3i + t2i; + p2->r = t3r - t2r; + p2->i = t3i - t2i; + } + } + + for (n5 = 0; n5 < 120; n5 += 24) + { + for (ind0 = n5; ind0 < (n5+8); ind0++) + { + p0 = x + ind0; + p1 = x + ind0 + 8; + p2 = x + ind0 + 16; + + t1r = p0->r + p1->r; + t1i = p0->i + p1->i; + cmpyj(p2); + + p1->r = t1r + p2->r; + p1->i = t1i + p2->i; + p2->r = t1r - p2->r; + p2->i = t1i - p2->i; + } + + } + + for (ind0 = 0; ind0 < 120; ind0 += 8) + { + p0 = x + ind0; + p1 = x + ind0 + 1; + p2 = x + ind0 + 2; + p3 = x + ind0 + 3; + p4 = x + ind0 + 4; + p5 = x + ind0 + 5; + p6 = x + ind0 + 6; + p7 = x + ind0 + 7; + + pi0 = xi + indxPost[ind0+0]; + pi1 = xi + indxPost[ind0+1]; + pi2 = xi + indxPost[ind0+2]; + pi3 = xi + indxPost[ind0+3]; + pi4 = xi + indxPost[ind0+4]; + pi5 = xi + indxPost[ind0+5]; + pi6 = xi + indxPost[ind0+6]; + pi7 = xi + indxPost[ind0+7]; + + cmpyj(p3); + cmpyj(p5); + cmpyj(p6); + + t5r = p4->r + p5->r; + t5i = p4->i + p5->i; + t4r = p4->r - p5->r; + t4i = p4->i - p5->i; + t7r = p6->r + p7->r; + t7i = p6->i + p7->i; + t6r = p6->r - p7->r; + t6i = p6->i - p7->i; + + cadd(*p0, *p1, pi0); + csub(*p0, *p1, pi4); + cadd(*p2, *p3, pi2); + csub(*p2, *p3, pi6); + pi1->r = t5r + t7r; + pi1->i = t5i + t7i; + pi5->r = t4r + t6r; + pi5->i = t4i + t6i; + pi3->r = t5r - t7r; + pi3->i = t5i - t7i; + pi7->r = t4r - t6r; + pi7->i = t4i - t6i; + } + + return; +} + +/*--------------------------------------------------------------------------*/ +/* Function wfft480 */ +/* ~~~~~~~~~~~~~~~~~ */ +/* */ +/* Winograd 480 points FFT */ +/*--------------------------------------------------------------------------*/ +/* complex *pI (i) input to the FFT */ +/* complex *pO (o) output to the FFT */ +/*--------------------------------------------------------------------------*/ +static void wfft480(complex *pI, complex *pO) +{ + short i, j; + float temp; + float x0r, x1r, x2r, x3r, t0r, t1r, t2r, t3r; + float x0i, x1i, x2i, x3i, t0i, t1i, t2i, t3i; + complex *pw1, *pw2, *pw3; + complex *pt0, *pt1, *pt2, *pt3; + + pt0 = pI; + pt1 = pI + 120; + pt2 = pI + 240; + pt3 = pI + 360; + pw1 = ptwdf + 1; + pw2 = ptwdf + 2; + pw3 = ptwdf + 3; + + for(i = 0; i < 120; i++) + { + t0r = pt0->r + pt2->r; + t0i = pt0->i + pt2->i; + t2r = pt0->r - pt2->r; + t2i = pt0->i - pt2->i; + t1r = pt1->r + pt3->r; + t1i = pt1->i + pt3->i; + t3r = pt3->r - pt1->r; + t3i = pt3->i - pt1->i; + + temp = t3r; + t3r = -t3i; + t3i = temp; + + x0r = t0r + t1r; + x0i = t0i + t1i; + x1r = t2r + t3r; + x1i = t2i + t3i; + x2r = t0r - t1r; + x2i = t0i - t1i; + x3r = t2r - t3r; + x3i = t2i - t3i; + + // twiddle factors + pt0->r = x0r; + pt0->i = x0i; + pt1->r = x1r * pw1->r - x1i * pw1->i; + pt1->i = x1r * pw1->i + x1i * pw1->r; + pt2->r = x2r * pw2->r - x2i * pw2->i; + pt2->i = x2r * pw2->i + x2i * pw2->r; + pt3->r = x3r * pw3->r - x3i * pw3->i; + pt3->i = x3r * pw3->i + x3i * pw3->r; + + pt0++; + pt1++; + pt2++; + pt3++; + pw1 += 4; + pw2 += 4; + pw3 += 4; + } + for(i = 0; i < 480; i+=120) + { + wfft120(pI+i); + } + + pt0 = pO; + for(j = 0; j < 120; j++) + { + pt1 = pI + j; + for(i = 0; i < 4; i++) + { + *pt0++ = *pt1; + pt1 += 120; + } + } + return; +} + +/*--------------------------------------------------------------------------*/ +/* Function dct4_960 */ +/* ~~~~~~~~~~~~~~~~~~ */ +/* */ +/* DCT4 960 points */ +/*--------------------------------------------------------------------------*/ +/* float v[] (i) input of the DCT4 */ +/* float coefs32[] (o) coefficient of the DCT4 */ +/*--------------------------------------------------------------------------*/ +void dct4_960(float v[MLT960_LENGTH], float coefs32[MLT960_LENGTH]) +{ + short n; + float f_int[MLT960_LENGTH]; + + for(n = 0; n < MLT960_LENGTH; n += 2) + { + f_int[n] = ((v[n] * dct480_table_1[n>>1].r - + v[(MLT960_LENGTH_MINUS_1-n)] * dct480_table_1[n>>1].i)); + f_int[n+1] = ((v[n] * dct480_table_1[n>>1].i + + v[(MLT960_LENGTH_MINUS_1-n)] * dct480_table_1[n>>1].r)); + } + + wfft480((complex *)f_int, (complex *)v); + + for(n = 0; n < MLT960_LENGTH; n += 2) + { + coefs32[n] = ((v[n] * dct480_table_2[n>>1].r - + v[n+1] * dct480_table_2[n>>1].i))/4.0f; + coefs32[MLT960_LENGTH_MINUS_1-n] = -(v[n] * dct480_table_2[n>>1].i + + v[n+1] * dct480_table_2[n>>1].r)/4.0f; + } +} + + +/*--------------------------------------------------------------------------*/ +/* Function dct4_240 */ +/* ~~~~~~~~~~~~~~~~~~ */ +/* */ +/* DCT4 240 points */ +/*--------------------------------------------------------------------------*/ +/* float v[] (i) input of the DCT4 */ +/* float coefs32[] (o) coefficient of the DCT4 */ +/*--------------------------------------------------------------------------*/ +void dct4_240(float v[MLT240_LENGTH], float coefs32[MLT240_LENGTH]) +{ + short n; + float f_int[MLT240_LENGTH]; + + for (n=0; n < MLT240_LENGTH; n+=2) + { + f_int[n] = (v[n]*dct120_table_1[n>>1].r - + v[(MLT240_LENGTH_MINUS_1-n)]*dct120_table_1[n>>1].i); + f_int[n+1] = (v[n]*dct120_table_1[n>>1].i + + v[(MLT240_LENGTH_MINUS_1-n)]*dct120_table_1[n>>1].r); + } + + wfft120((complex *)f_int); + + for (n=0; n < MLT240_LENGTH; n+=2) + { + coefs32[n] = (f_int[n]*dct120_table_2[n>>1].r - + f_int[n+1]*dct120_table_2[n>>1].i)/2.0f; + coefs32[MLT240_LENGTH_MINUS_1-n] = -(f_int[n]*dct120_table_2[n>>1].i + + f_int[n+1]*dct120_table_2[n>>1].r)/2.0f; + } +} + diff --git a/Frameworks/g719/g719/reference_code/common/idx2code.c b/Frameworks/g719/g719/reference_code/common/idx2code.c new file mode 100755 index 000000000..bbfee7aa1 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/common/idx2code.c @@ -0,0 +1,60 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "proto.h" +#include "cnst.h" +#include "rom.h" + +/*--------------------------------------------------------------------------*/ +/* Function idx2code */ +/* ~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Finding a codevector from its index */ +/*--------------------------------------------------------------------------*/ +/* short *k (i) index of the codevector */ +/* short *y (o) codevector */ +/* short R (i) number of bits per coefficient */ +/*--------------------------------------------------------------------------*/ +void idx2code(short *k, short *y, short R) +{ + short i, m, tmp; + short v[8], z[8]; + + + tmp = FacLVQ2Qv[R] - R; + m = k[0] << 1; + for (i=1; i<8; i++) + { + m += k[i]; + } + if (tmp<0) + { + z[0] = m >> (-tmp); + } + else + { + z[0] = m << tmp; + } + for (i=1; i<8; i++) + { + if (tmp<0) + { + z[i] = k[i] >> (-tmp); + } + else + { + z[i] = k[i] << tmp; + } + } + codesearch(z, v, R); + y[0] = m - (v[0] << R); + for (i=1; i<8; i++) + { + y[i] = k[i] - (v[i] << R); + } + + return; +} diff --git a/Frameworks/g719/g719/reference_code/common/interleave_spectrum.c b/Frameworks/g719/g719/reference_code/common/interleave_spectrum.c new file mode 100755 index 000000000..4c8b79606 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/common/interleave_spectrum.c @@ -0,0 +1,165 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "cnst.h" + +/*--------------------------------------------------------------------------*/ +/* Function interleave_spectrum */ +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Interleave the spectrum */ +/*--------------------------------------------------------------------------*/ +/* float *coefs (i/o) input and output coefficients */ +/*--------------------------------------------------------------------------*/ +void interleave_spectrum(float *coefs) +{ + short i, j; + float *p1a, *p1b, *p2a, *p2b, *p3a, *p3b, *p3c, *p4a, *p4b; + float coefs_short[STOP_BAND]; + float *pcoefs, *pcoefs1, *pcoefs2; + + p1a = coefs_short; + pcoefs = coefs; + + for (i = 0; i < 4; i++) + { + for (j = 0; j < STOP_BAND4; j++) + { + p1a[j] = pcoefs[j]; + } + p1a += STOP_BAND4; + pcoefs += FRAME_LENGTH/4; + } + + p1a = coefs; + p1b = coefs + 64; + p2a = coefs + NUMC_G1; + p2b = coefs + NUMC_G1 + 64; + p3a = coefs + NUMC_G23; + p3b = coefs + NUMC_G23 + 96; + p3c = coefs + NUMC_G23 + 192; + p4a = coefs + NUMC_N; + p4b = coefs + NUMC_N + 128; + for (i = 0; i < STOP_BAND; i += STOP_BAND4) + { + pcoefs = coefs_short + i; + pcoefs1 = coefs_short + 16 + i; + for (j = 0; j < 16; j++) + { + *p1a++ = *pcoefs++; + *p1b++ = *pcoefs1++; + } + + pcoefs = coefs_short + NUMC_G1SUB + i; + pcoefs1 = coefs_short + NUMC_G1SUB + 16 + i; + for (j = 0; j < 16; j++) + { + *p2a++ = *pcoefs++; + *p2b++ = *pcoefs1++; + } + + pcoefs = coefs_short + NUMC_G1G2SUB + i; + pcoefs1 = coefs_short + NUMC_G1G2SUB + WID_G3 + i; + pcoefs2 = coefs_short + NUMC_G1G2SUB + 2 * WID_G3 + i; + for (j = 0; j < WID_G3; j++) + { + *p3a++ = *pcoefs++; + *p3b++ = *pcoefs1++; + *p3c++ = *pcoefs2++; + } + + pcoefs = coefs_short + NUMC_G1G2G3SUB + i; + pcoefs1 = coefs_short + NUMC_G1G2G3SUB + WID_GX + i; + for (j = 0; j < WID_GX; j++) + { + *p4a++ = *pcoefs++; + *p4b++ = *pcoefs1++; + } + } + +} + +/*--------------------------------------------------------------------------*/ +/* Function de_interleave_spectrum */ +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Deinterleave the spectrum */ +/*--------------------------------------------------------------------------*/ +/* float *coefs (i/o) input and output coefficients */ +/*--------------------------------------------------------------------------*/ +void de_interleave_spectrum(float *coefs) +{ + short i, j; + float coefs_short[STOP_BAND]; + float *p1a, *p1b, *p2a, *p2b, *p3a, *p3b, *p3c, *p4a, *p4b; + float *pcoefs, *pcoefs1, *pcoefs2; + + + p1a = coefs; + p1b = coefs + 64; + p2a = coefs + NUMC_G1; + p2b = coefs + NUMC_G1 + 64; + p3a = coefs + NUMC_G23; + p3b = coefs + NUMC_G23 + 96; + p3c = coefs + NUMC_G23 + 192; + p4a = coefs + NUMC_N; + p4b = coefs + NUMC_N + 128; + for (i=0; i + +/*--------------------------------------------------------------------------*/ +/* Function sfm2mqb */ +/* ~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Map sub-vectors to pbands */ +/*--------------------------------------------------------------------------*/ +/* short spe[] (i) sub-vectors */ +/* short spe2q[] (o) pbands */ +/*--------------------------------------------------------------------------*/ +static void sfm2mqb(short spe[], short spe2q[]) +{ + short tmp,i; + + /* short groups */ + spe2q[0] = spe[0] + 3; + spe2q[1] = spe[1] + 3; + spe2q[2] = spe[2] + 3; + spe2q[3] = spe[3] + 3; + spe2q[4] = spe[4] + 3; + spe2q[5] = spe[5] + 3; + spe2q[6] = spe[6] + 3; + spe2q[7] = spe[7] + 3; + spe2q[8] = spe[8] + 3; + spe2q[9] = spe[9] + 3; + + spe2q[10] = ((spe[10] + spe[11]) >> 1) + 4; + spe2q[11] = ((spe[12] + spe[13]) >> 1) + 4; + spe2q[12] = ((spe[14] + spe[15]) >> 1) + 4; + + spe2q[13] = ((spe[16] + spe[17]) >> 1) + 5; + spe2q[14] = ((spe[18] + spe[19]) >> 1) + 5; + + tmp = 0; + for (i=20; i < 24; i++) + { + tmp += spe[i]; + } + spe2q[15] = (short)(((int)tmp * 8192L) >> 15) + 6; + + tmp = 0; + for (i=24; i < 27; i++) + { + tmp += spe[i]; + } + spe2q[16] = (short)(((int)tmp * 10923L) >> 15) + 6; + + tmp = 0; + for (i=27; i < 30; i++) + { + tmp += spe[i]; + } + spe2q[17] = (short)(((int)tmp * 10923L) >> 15) + 6; + + tmp = 0; + for (i=30; i < 35; i++) + { + tmp += spe[i]; + } + spe2q[18] = (short)(((int)tmp * 6553L) >> 15) + 7; + + tmp = 0; + for (i=35; i < 44; i++) { + tmp += spe[i]; + } + spe2q[19] = (short)(((int)tmp * 3641L) >> 15) + 8; +} + +/*--------------------------------------------------------------------------*/ +/* Function mqb2sfm */ +/* ~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Map pbands to sub-vectors */ +/*--------------------------------------------------------------------------*/ +/* short spe2q[] (i) pbands */ +/* short spe[] (o) sub-vectors */ +/*--------------------------------------------------------------------------*/ +static void mqb2sfm(short spe2q[],short spe[]) +{ + short i; + + spe[0] = spe2q[0]; + spe[1] = spe2q[1]; + spe[2] = spe2q[2]; + spe[3] = spe2q[3]; + spe[4] = spe2q[4]; + spe[5] = spe2q[5]; + spe[6] = spe2q[6]; + spe[7] = spe2q[7]; + spe[8] = spe2q[8]; + spe[9] = spe2q[9]; + + spe[10] = spe2q[10]; + spe[11] = spe2q[10]; + + spe[12] = spe2q[11]; + spe[13] = spe2q[11]; + + spe[14] = spe2q[12]; + spe[15] = spe2q[12]; + + spe[16] = spe2q[13]; + spe[17] = spe2q[13]; + + spe[18] = spe2q[14]; + spe[19] = spe2q[14]; + + for (i=20; i < 24; i++) + { + spe[i] = spe2q[15]; + } + + for (i=24; i < 27; i++) + { + spe[i] = spe2q[16]; + } + + for (i=27; i < 30; i++) + { + spe[i] = spe2q[17]; + } + + for (i=30; i < 35; i++) + { + spe[i] = spe2q[18]; + } + + for (i=35; i < 44; i++) + { + spe[i] = spe2q[19]; + } +} + +/*--------------------------------------------------------------------------*/ +/* Function map_quant_weight */ +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Calculate the quantization weights */ +/*--------------------------------------------------------------------------*/ +/* short normqlg2[] (i) quantized norms */ +/* short wnorm[] (o) weighted norm */ +/* short is_transient (i) transient flag */ +/*--------------------------------------------------------------------------*/ +void map_quant_weight(short normqlg2[], short wnorm[], short is_transient) +{ + short sfm; + short tmp16; + short spe2q[NUM_MAP_BANDS]; + short spe[NB_SFM]; + + short spe2q_max; + short spe2q_min; + short norm_max; + short shift; + short sum; + short k; + + if (is_transient) + { + for (sfm = 0; sfm < NB_SFM; sfm+=4) + { + sum = 0; + for (k=0; k < 4; k++) { + sum = sum + normqlg2[sfm+k]; + } + sum = sum >> 2; + + for (k=0; k < 4; k++) + { + spe[sfm +k] = sum; + } + } + } + else { + for (sfm = 0; sfm < NB_SFM; sfm++) + { + spe[sfm] = normqlg2[sfm]; + } + } + + sfm2mqb(spe, spe2q); + + for (sfm = 0; sfm < NUM_MAP_BANDS; sfm++) + { + spe2q[sfm] = spe2q[sfm] - 10; + } + + /* spectral smoothing */ + for (sfm = 1; sfm < NUM_MAP_BANDS; sfm++) + { + tmp16 = spe2q[sfm-1] - 4; + if (spe2q[sfm]= 0 ; sfm--) + { + tmp16 = spe2q[sfm+1] - 8; + if (spe2q[sfm]spe2q[sfm]) + { + spe2q_min = spe2q[sfm]; + } + } + + for (sfm = 0; sfm < NUM_MAP_BANDS ; sfm++) + { + spe2q[sfm] = spe2q[sfm] - spe2q_min; + } + + spe2q_max = spe2q_max - spe2q_min; + + if (spe2q_max==0) + { + norm_max = 0; + } + else + { + if (spe2q_max<0) + { + spe2q_max = ~spe2q_max; + } + for (norm_max=0; spe2q_max<0x4000; norm_max++) + { + spe2q_max <<= 1; + } + } + + shift = norm_max - 13; + + for (sfm = 0; sfm < NUM_MAP_BANDS ; sfm++) + { + if (shift<0) + { + spe2q[sfm] = spe2q[sfm] >> (-shift); + } + else + { + spe2q[sfm] = spe2q[sfm] << shift; + } + } + + mqb2sfm(spe2q,spe); + + if (is_transient) + { + for (sfm = 0; sfm < NB_SFM; sfm+=4) + { + sum = 0; + for (k=0; k < 4; k++) { + sum = sum + spe[sfm+k]; + } + sum = sum >> 2; + + for (k=0; k < 4; k++) + { + spe[sfm +k] = sum; + } + } + } + + /* modify the norms for bit-allocation */ + for (sfm = 0; sfm < NB_SFM ; sfm++) + { + wnorm[sfm] = spe[sfm] + normqlg2[sfm]; + } + +} diff --git a/Frameworks/g719/g719/reference_code/decoder/decode_frame.c b/Frameworks/g719/g719/reference_code/decoder/decode_frame.c new file mode 100755 index 000000000..d89a6751d --- /dev/null +++ b/Frameworks/g719/g719/reference_code/decoder/decode_frame.c @@ -0,0 +1,96 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "state.h" +#include "cnst.h" +#include "proto.h" + +/*--------------------------------------------------------------------------*/ +/* Function decode_frame */ +/* ~~~~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Decodes a single frame */ +/*--------------------------------------------------------------------------*/ +/* short bitstream[] (i) bitstream to decode */ +/* short bfi (i) bad frame indicator */ +/* short out16[] (o) decoded audio */ +/* DecoderState *d (i/o) state of decoder */ +/*--------------------------------------------------------------------------*/ +void decode_frame(short bitstream[], + short bfi, + short out16[], + DecoderState *d) +{ + short is_transient; + float t_audio_q[FRAME_LENGTH]; + float wtda_audio[2*FRAME_LENGTH]; + short bitalloc[NB_SFM]; + short ynrm[NB_SFM]; + short i; + float audio_q_norm[FREQ_LENGTH]; + short nf_idx; + short **pbitstream; + short *tbitstream; + + if (bfi) + { + for (i=0; i < FRAME_LENGTH; i++) + { + t_audio_q[i] = d->old_coeffs[i]; + d->old_coeffs[i] = d->old_coeffs[i]/2; + } + is_transient = d->old_is_transient; + } + else + { + if (*bitstream == G192_BIT1) + { + is_transient = 1; + } + else + { + is_transient = 0; + } + + bitstream++; + + tbitstream = bitstream; + pbitstream = &bitstream; + if (is_transient) + { + flvqdec(pbitstream, t_audio_q, audio_q_norm, bitalloc, (short)d->num_bits_spectrum_transient, ynrm, is_transient); + nf_idx = 0; + } + else + { + flvqdec(pbitstream, t_audio_q, audio_q_norm, bitalloc, (short)d->num_bits_spectrum_stationary, ynrm, is_transient); + bits2idxn(bitstream, 2, &nf_idx); + bitstream += 2; + } + + for (i = FREQ_LENGTH; i < FRAME_LENGTH; i++) + { + t_audio_q[i] = 0.0f; + } + + fill_spectrum(audio_q_norm, t_audio_q, bitalloc, is_transient, ynrm, nf_idx); + + if (is_transient) + { + de_interleave_spectrum(t_audio_q); + } + + for (i=0; i < FRAME_LENGTH; i++) + { + d->old_coeffs[i] = t_audio_q[i]; + + } + d->old_is_transient = is_transient; + } + + inverse_transform(t_audio_q, wtda_audio, is_transient); + window_ola(wtda_audio, out16, d->old_out); +} diff --git a/Frameworks/g719/g719/reference_code/decoder/decoder_init.c b/Frameworks/g719/g719/reference_code/decoder/decoder_init.c new file mode 100755 index 000000000..2015f2b85 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/decoder/decoder_init.c @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "state.h" +#include "cnst.h" +#include "rom.h" + +/*--------------------------------------------------------------------------*/ +/* Function decoder_reset_tables */ +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Reset decoder tables */ +/*--------------------------------------------------------------------------*/ +/* decoderState *d (i) state of decoder */ +/* short num_bits (i) number of bits */ +/*--------------------------------------------------------------------------*/ +void decoder_reset_tables(DecoderState *d, short num_bits) +{ + d->num_bits_spectrum_stationary = num_bits - 3; + d->num_bits_spectrum_transient = num_bits - 1; + d->num_bits = num_bits; +} + +/*--------------------------------------------------------------------------*/ +/* Function decoder_init */ +/* ~~~~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Initialize the state of the decoder */ +/*--------------------------------------------------------------------------*/ +/* DecoderState *d (i) state of decoder */ +/* short num_bits (i) number of bits */ +/*--------------------------------------------------------------------------*/ +void decoder_init(DecoderState *d, short num_bits) +{ + short i; + + for (i=0 ; i < FRAME_LENGTH ; i++) + { + d->old_out[i] = 0.0f; + } + + d->old_is_transient = 0; + + decoder_reset_tables(d, num_bits); +} diff --git a/Frameworks/g719/g719/reference_code/decoder/decoder_rom.c b/Frameworks/g719/g719/reference_code/decoder/decoder_rom.c new file mode 100755 index 000000000..c101c1633 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/decoder/decoder_rom.c @@ -0,0 +1,348 @@ +/*-----------------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*-----------------------------------------------------------------------------------*/ + +float short_window[480] = { +0.00326538f,0.00982666f,0.0163574f, 0.0229187f, 0.0294495f, 0.0359802f, +0.0425415f, 0.0490723f, 0.055603f, 0.0621338f, 0.0686646f, 0.0751953f, +0.0817261f, 0.0882568f, 0.0947571f, 0.101288f, 0.107788f, 0.114288f, +0.120789f, 0.127289f, 0.133759f, 0.140259f, 0.146729f, 0.153198f, +0.159668f, 0.166138f, 0.172577f, 0.179016f, 0.185455f, 0.191895f, +0.198303f, 0.204712f, 0.211121f, 0.217499f, 0.223877f, 0.230255f, +0.236633f, 0.242981f, 0.249329f, 0.255646f, 0.261993f, 0.26828f, +0.274597f, 0.280884f, 0.28714f, 0.293427f, 0.299652f, 0.305908f, +0.312134f, 0.318329f, 0.324524f, 0.330719f, 0.336884f, 0.343048f, +0.349182f, 0.355316f, 0.36142f, 0.367523f, 0.373596f, 0.379669f, +0.385712f, 0.391724f, 0.397736f, 0.403748f, 0.409729f, 0.41568f, +0.421631f, 0.427551f, 0.433472f, 0.439362f, 0.445221f, 0.45108f, +0.456909f, 0.462708f, 0.468506f, 0.474274f, 0.480042f, 0.485748f, +0.491486f, 0.497162f, 0.502838f, 0.508484f, 0.514099f, 0.519714f, +0.525299f, 0.530853f, 0.536377f, 0.541901f, 0.547394f, 0.552856f, +0.558289f, 0.563721f, 0.569092f, 0.574463f, 0.579803f, 0.585144f, +0.590424f, 0.595703f, 0.600952f, 0.606171f, 0.611359f, 0.616516f, +0.621674f, 0.62677f, 0.631866f, 0.636932f, 0.641937f, 0.646942f, +0.651947f, 0.656891f, 0.661804f, 0.666687f, 0.67157f, 0.676392f, +0.681213f, 0.685974f, 0.690735f, 0.695435f, 0.700134f, 0.704803f, +0.709412f, 0.71402f, 0.718567f, 0.723114f, 0.727631f, 0.732086f, +0.736542f, 0.740936f, 0.745331f, 0.749664f, 0.753998f, 0.75827f, +0.762512f, 0.766754f, 0.770935f, 0.775085f, 0.779205f, 0.783295f, +0.787354f, 0.791351f, 0.795349f, 0.799286f, 0.803223f, 0.807098f, +0.810944f, 0.814758f, 0.818512f, 0.822266f, 0.825989f, 0.829651f, +0.833282f, 0.836884f, 0.840454f, 0.843964f, 0.847473f, 0.850922f, +0.85434f, 0.857727f, 0.861084f, 0.86438f, 0.867645f, 0.87088f, +0.874084f, 0.877258f, 0.880371f, 0.883453f, 0.886505f, 0.889526f, +0.892487f, 0.895416f, 0.898315f, 0.901184f, 0.903992f, 0.906769f, +0.909515f, 0.912201f, 0.914886f, 0.91748f, 0.920074f, 0.922607f, +0.92514f, 0.927582f, 0.930023f, 0.932404f, 0.934753f, 0.937042f, +0.939331f, 0.941559f, 0.943726f, 0.945862f, 0.947968f, 0.950043f, +0.952057f, 0.954041f, 0.955994f, 0.957886f, 0.959747f, 0.961548f, +0.963348f, 0.965088f, 0.966766f, 0.968414f, 0.970032f, 0.971588f, +0.973114f, 0.974609f, 0.976074f, 0.977448f, 0.978821f, 0.980133f, +0.981415f, 0.982666f, 0.983856f, 0.984985f, 0.986115f, 0.987183f, +0.98819f, 0.989166f, 0.990112f, 0.990997f, 0.991852f, 0.992676f, +0.993439f, 0.994171f, 0.994873f, 0.995514f, 0.996094f, 0.996643f, +0.997162f, 0.99765f, 0.998077f, 0.998444f, 0.99881f, 0.999084f, +0.999359f, 0.999573f, 0.999725f, 0.999878f, 0.999939f, 0.999969f, +0.999969f, 0.999939f, 0.999878f, 0.999725f, 0.999573f, 0.999359f, +0.999084f, 0.99881f, 0.998444f, 0.998077f, 0.99765f, 0.997162f, +0.996643f, 0.996094f, 0.995514f, 0.994873f, 0.994171f, 0.993439f, +0.992676f, 0.991852f, 0.990997f, 0.990112f, 0.989166f, 0.98819f, +0.987183f, 0.986115f, 0.984985f, 0.983856f, 0.982666f, 0.981415f, +0.980133f, 0.978821f, 0.977448f, 0.976074f, 0.974609f, 0.973114f, +0.971588f, 0.970032f, 0.968414f, 0.966766f, 0.965088f, 0.963348f, +0.961548f, 0.959747f, 0.957886f, 0.955994f, 0.954041f, 0.952057f, +0.950043f, 0.947968f, 0.945862f, 0.943726f, 0.941559f, 0.939331f, +0.937042f, 0.934753f, 0.932404f, 0.930023f, 0.927582f, 0.92514f, +0.922607f, 0.920074f, 0.91748f, 0.914886f, 0.912201f, 0.909515f, +0.906769f, 0.903992f, 0.901184f, 0.898315f, 0.895416f, 0.892487f, +0.889526f, 0.886505f, 0.883453f, 0.880371f, 0.877258f, 0.874084f, +0.87088f, 0.867645f, 0.86438f, 0.861084f, 0.857727f, 0.85434f, +0.850922f, 0.847473f, 0.843964f, 0.840454f, 0.836884f, 0.833282f, +0.829651f, 0.825989f, 0.822266f, 0.818512f, 0.814758f, 0.810944f, +0.807098f, 0.803223f, 0.799286f, 0.795349f, 0.791351f, 0.787354f, +0.783295f, 0.779205f, 0.775085f, 0.770935f, 0.766754f, 0.762512f, +0.75827f, 0.753998f, 0.749664f, 0.745331f, 0.740936f, 0.736542f, +0.732086f, 0.727631f, 0.723114f, 0.718567f, 0.71402f, 0.709412f, +0.704803f, 0.700134f, 0.695435f, 0.690735f, 0.685974f, 0.681213f, +0.676392f, 0.67157f, 0.666687f, 0.661804f, 0.656891f, 0.651947f, +0.646942f, 0.641937f, 0.636932f, 0.631866f, 0.62677f, 0.621674f, +0.616516f, 0.611359f, 0.606171f, 0.600952f, 0.595703f, 0.590424f, +0.585144f, 0.579803f, 0.574463f, 0.569092f, 0.563721f, 0.558289f, +0.552856f, 0.547394f, 0.541901f, 0.536377f, 0.530853f, 0.525299f, +0.519714f, 0.514099f, 0.508484f, 0.502838f, 0.497162f, 0.491486f, +0.485748f, 0.480042f, 0.474274f, 0.468506f, 0.462708f, 0.456909f, +0.45108f, 0.445221f, 0.439362f, 0.433472f, 0.427551f, 0.421631f, +0.41568f, 0.409729f, 0.403748f, 0.397736f, 0.391724f, 0.385712f, +0.379669f, 0.373596f, 0.367523f, 0.36142f, 0.355316f, 0.349182f, +0.343048f, 0.336884f, 0.330719f, 0.324524f, 0.318329f, 0.312134f, +0.305908f, 0.299652f, 0.293427f, 0.28714f, 0.280884f, 0.274597f, +0.26828f, 0.261993f, 0.255646f, 0.249329f, 0.242981f, 0.236633f, +0.230255f, 0.223877f, 0.217499f, 0.211121f, 0.204712f, 0.198303f, +0.191895f, 0.185455f, 0.179016f, 0.172577f, 0.166138f, 0.159668f, +0.153198f, 0.146729f, 0.140259f, 0.133759f, 0.127289f, 0.120789f, +0.114288f, 0.107788f, 0.101288f, 0.0947571f, 0.0882568f, 0.0817261f, +0.0751953f, 0.0686646f, 0.0621338f, 0.055603f, 0.0490723f, 0.0425415f, +0.0359802f, 0.0294495f, 0.0229187f, 0.0163574f, 0.00982666f,0.00326538f +}; + +short dic4[256][8] = { +{-2, 0, 0, 0, 0, 0, 0, 0}, +{ 0, -2, 0, 0, 0, 0, 0, 0}, +{ 0, 0, -2, 0, 0, 0, 0, 0}, +{ 0, 0, 0, -2, 0, 0, 0, 0}, +{ 0, 0, 0, 0, -2, 0, 0, 0}, +{ 0, 0, 0, 0, 0, -2, 0, 0}, +{ 0, 0, 0, 0, 0, 0, -2, 0}, +{ 0, 0, 0, 0, 0, 0, 0, -2}, +{ 2, 0, 0, 0, 0, 0, 0, 0}, +{ 0, 2, 0, 0, 0, 0, 0, 0}, +{ 0, 0, 2, 0, 0, 0, 0, 0}, +{ 0, 0, 0, 2, 0, 0, 0, 0}, +{ 0, 0, 0, 0, 2, 0, 0, 0}, +{ 0, 0, 0, 0, 0, 2, 0, 0}, +{ 0, 0, 0, 0, 0, 0, 2, 0}, +{ 0, 0, 0, 0, 0, 0, 0, 2}, +{-2, -2, 0, 0, 0, 0, 0, 0}, +{-2, 0, -2, 0, 0, 0, 0, 0}, +{-2, 0, 0, -2, 0, 0, 0, 0}, +{-2, 0, 0, 0, -2, 0, 0, 0}, +{-2, 0, 0, 0, 0, -2, 0, 0}, +{-2, 0, 0, 0, 0, 0, -2, 0}, +{-2, 0, 0, 0, 0, 0, 0, -2}, +{ 0, -2, -2, 0, 0, 0, 0, 0}, +{ 0, -2, 0, -2, 0, 0, 0, 0}, +{ 0, -2, 0, 0, -2, 0, 0, 0}, +{ 0, -2, 0, 0, 0, -2, 0, 0}, +{ 0, -2, 0, 0, 0, 0, -2, 0}, +{ 0, -2, 0, 0, 0, 0, 0, -2}, +{ 0, 0, -2, -2, 0, 0, 0, 0}, +{ 0, 0, -2, 0, -2, 0, 0, 0}, +{ 0, 0, -2, 0, 0, -2, 0, 0}, +{ 0, 0, -2, 0, 0, 0, -2, 0}, +{ 0, 0, -2, 0, 0, 0, 0, -2}, +{ 0, 0, 0, -2, -2, 0, 0, 0}, +{ 0, 0, 0, -2, 0, -2, 0, 0}, +{ 0, 0, 0, -2, 0, 0, -2, 0}, +{ 0, 0, 0, -2, 0, 0, 0, -2}, +{ 0, 0, 0, 0, -2, -2, 0, 0}, +{ 0, 0, 0, 0, -2, 0, -2, 0}, +{ 0, 0, 0, 0, -2, 0, 0, -2}, +{ 0, 0, 0, 0, 0, -2, -2, 0}, +{ 0, 0, 0, 0, 0, -2, 0, -2}, +{ 0, 0, 0, 0, 0, 0, -2, -2}, +{-2, 2, 0, 0, 0, 0, 0, 0}, +{-2, 0, 2, 0, 0, 0, 0, 0}, +{-2, 0, 0, 2, 0, 0, 0, 0}, +{-2, 0, 0, 0, 2, 0, 0, 0}, +{-2, 0, 0, 0, 0, 2, 0, 0}, +{-2, 0, 0, 0, 0, 0, 2, 0}, +{-2, 0, 0, 0, 0, 0, 0, 2}, +{ 0, -2, 2, 0, 0, 0, 0, 0}, +{ 0, -2, 0, 2, 0, 0, 0, 0}, +{ 0, -2, 0, 0, 2, 0, 0, 0}, +{ 0, -2, 0, 0, 0, 2, 0, 0}, +{ 0, -2, 0, 0, 0, 0, 2, 0}, +{ 0, -2, 0, 0, 0, 0, 0, 2}, +{ 0, 0, -2, 2, 0, 0, 0, 0}, +{ 0, 0, -2, 0, 2, 0, 0, 0}, +{ 0, 0, -2, 0, 0, 2, 0, 0}, +{ 0, 0, -2, 0, 0, 0, 2, 0}, +{ 0, 0, -2, 0, 0, 0, 0, 2}, +{ 0, 0, 0, -2, 2, 0, 0, 0}, +{ 0, 0, 0, -2, 0, 2, 0, 0}, +{ 0, 0, 0, -2, 0, 0, 2, 0}, +{ 0, 0, 0, -2, 0, 0, 0, 2}, +{ 0, 0, 0, 0, -2, 2, 0, 0}, +{ 0, 0, 0, 0, -2, 0, 2, 0}, +{ 0, 0, 0, 0, -2, 0, 0, 2}, +{ 0, 0, 0, 0, 0, -2, 2, 0}, +{ 0, 0, 0, 0, 0, -2, 0, 2}, +{ 0, 0, 0, 0, 0, 0, -2, 2}, +{ 2, -2, 0, 0, 0, 0, 0, 0}, +{ 2, 0, -2, 0, 0, 0, 0, 0}, +{ 2, 0, 0, -2, 0, 0, 0, 0}, +{ 2, 0, 0, 0, -2, 0, 0, 0}, +{ 2, 0, 0, 0, 0, -2, 0, 0}, +{ 2, 0, 0, 0, 0, 0, -2, 0}, +{ 2, 0, 0, 0, 0, 0, 0, -2}, +{ 0, 2, -2, 0, 0, 0, 0, 0}, +{ 0, 2, 0, -2, 0, 0, 0, 0}, +{ 0, 2, 0, 0, -2, 0, 0, 0}, +{ 0, 2, 0, 0, 0, -2, 0, 0}, +{ 0, 2, 0, 0, 0, 0, -2, 0}, +{ 0, 2, 0, 0, 0, 0, 0, -2}, +{ 0, 0, 2, -2, 0, 0, 0, 0}, +{ 0, 0, 2, 0, -2, 0, 0, 0}, +{ 0, 0, 2, 0, 0, -2, 0, 0}, +{ 0, 0, 2, 0, 0, 0, -2, 0}, +{ 0, 0, 2, 0, 0, 0, 0, -2}, +{ 0, 0, 0, 2, -2, 0, 0, 0}, +{ 0, 0, 0, 2, 0, -2, 0, 0}, +{ 0, 0, 0, 2, 0, 0, -2, 0}, +{ 0, 0, 0, 2, 0, 0, 0, -2}, +{ 0, 0, 0, 0, 2, -2, 0, 0}, +{ 0, 0, 0, 0, 2, 0, -2, 0}, +{ 0, 0, 0, 0, 2, 0, 0, -2}, +{ 0, 0, 0, 0, 0, 2, -2, 0}, +{ 0, 0, 0, 0, 0, 2, 0, -2}, +{ 0, 0, 0, 0, 0, 0, 2, -2}, +{ 2, 2, 0, 0, 0, 0, 0, 0}, +{ 2, 0, 2, 0, 0, 0, 0, 0}, +{ 2, 0, 0, 2, 0, 0, 0, 0}, +{ 2, 0, 0, 0, 2, 0, 0, 0}, +{ 2, 0, 0, 0, 0, 2, 0, 0}, +{ 2, 0, 0, 0, 0, 0, 2, 0}, +{ 2, 0, 0, 0, 0, 0, 0, 2}, +{ 0, 2, 2, 0, 0, 0, 0, 0}, +{ 0, 2, 0, 2, 0, 0, 0, 0}, +{ 0, 2, 0, 0, 2, 0, 0, 0}, +{ 0, 2, 0, 0, 0, 2, 0, 0}, +{ 0, 2, 0, 0, 0, 0, 2, 0}, +{ 0, 2, 0, 0, 0, 0, 0, 2}, +{ 0, 0, 2, 2, 0, 0, 0, 0}, +{ 0, 0, 2, 0, 2, 0, 0, 0}, +{ 0, 0, 2, 0, 0, 2, 0, 0}, +{ 0, 0, 2, 0, 0, 0, 2, 0}, +{ 0, 0, 2, 0, 0, 0, 0, 2}, +{ 0, 0, 0, 2, 2, 0, 0, 0}, +{ 0, 0, 0, 2, 0, 2, 0, 0}, +{ 0, 0, 0, 2, 0, 0, 2, 0}, +{ 0, 0, 0, 2, 0, 0, 0, 2}, +{ 0, 0, 0, 0, 2, 2, 0, 0}, +{ 0, 0, 0, 0, 2, 0, 2, 0}, +{ 0, 0, 0, 0, 2, 0, 0, 2}, +{ 0, 0, 0, 0, 0, 2, 2, 0}, +{ 0, 0, 0, 0, 0, 2, 0, 2}, +{ 0, 0, 0, 0, 0, 0, 2, 2}, +{-1, -1, 1, 1, 1, 1, 1, 1}, +{-1, 1, -1, 1, 1, 1, 1, 1}, +{-1, 1, 1, -1, 1, 1, 1, 1}, +{-1, 1, 1, 1, -1, 1, 1, 1}, +{-1, 1, 1, 1, 1, -1, 1, 1}, +{-1, 1, 1, 1, 1, 1, -1, 1}, +{-1, 1, 1, 1, 1, 1, 1, -1}, +{ 1, -1, -1, 1, 1, 1, 1, 1}, +{ 1, -1, 1, -1, 1, 1, 1, 1}, +{ 1, -1, 1, 1, -1, 1, 1, 1}, +{ 1, -1, 1, 1, 1, -1, 1, 1}, +{ 1, -1, 1, 1, 1, 1, -1, 1}, +{ 1, -1, 1, 1, 1, 1, 1, -1}, +{ 1, 1, -1, -1, 1, 1, 1, 1}, +{ 1, 1, -1, 1, -1, 1, 1, 1}, +{ 1, 1, -1, 1, 1, -1, 1, 1}, +{ 1, 1, -1, 1, 1, 1, -1, 1}, +{ 1, 1, -1, 1, 1, 1, 1, -1}, +{ 1, 1, 1, -1, -1, 1, 1, 1}, +{ 1, 1, 1, -1, 1, -1, 1, 1}, +{ 1, 1, 1, -1, 1, 1, -1, 1}, +{ 1, 1, 1, -1, 1, 1, 1, -1}, +{ 1, 1, 1, 1, -1, -1, 1, 1}, +{ 1, 1, 1, 1, -1, 1, -1, 1}, +{ 1, 1, 1, 1, -1, 1, 1, -1}, +{ 1, 1, 1, 1, 1, -1, -1, 1}, +{ 1, 1, 1, 1, 1, -1, 1, -1}, +{ 1, 1, 1, 1, 1, 1, -1, -1}, +{-1, -1, -1, -1, 1, 1, 1, 1}, +{-1, -1, -1, 1, -1, 1, 1, 1}, +{-1, -1, -1, 1, 1, -1, 1, 1}, +{-1, -1, -1, 1, 1, 1, -1, 1}, +{-1, -1, -1, 1, 1, 1, 1, -1}, +{-1, -1, 1, -1, -1, 1, 1, 1}, +{-1, -1, 1, -1, 1, -1, 1, 1}, +{-1, -1, 1, -1, 1, 1, -1, 1}, +{-1, -1, 1, -1, 1, 1, 1, -1}, +{-1, -1, 1, 1, -1, -1, 1, 1}, +{-1, -1, 1, 1, -1, 1, -1, 1}, +{-1, -1, 1, 1, -1, 1, 1, -1}, +{-1, -1, 1, 1, 1, 1, -1, -1}, +{-1, -1, 1, 1, 1, -1, 1, -1}, +{-1, -1, 1, 1, 1, -1, -1, 1}, +{-1, 1, -1, -1, -1, 1, 1, 1}, +{-1, 1, -1, -1, 1, -1, 1, 1}, +{-1, 1, -1, -1, 1, 1, -1, 1}, +{-1, 1, -1, -1, 1, 1, 1, -1}, +{-1, 1, -1, 1, -1, -1, 1, 1}, +{-1, 1, -1, 1, -1, 1, -1, 1}, +{-1, 1, -1, 1, -1, 1, 1, -1}, +{-1, 1, -1, 1, 1, 1, -1, -1}, +{-1, 1, -1, 1, 1, -1, 1, -1}, +{-1, 1, -1, 1, 1, -1, -1, 1}, +{-1, 1, 1, 1, 1, -1, -1, -1}, +{-1, 1, 1, 1, -1, 1, -1, -1}, +{-1, 1, 1, 1, -1, -1, 1, -1}, +{-1, 1, 1, 1, -1, -1, -1, 1}, +{-1, 1, 1, -1, -1, -1, 1, 1}, +{-1, 1, 1, -1, -1, 1, -1, 1}, +{-1, 1, 1, -1, -1, 1, 1, -1}, +{-1, 1, 1, -1, 1, 1, -1, -1}, +{-1, 1, 1, -1, 1, -1, 1, -1}, +{-1, 1, 1, -1, 1, -1, -1, 1}, +{ 1, 1, 1, 1, -1, -1, -1, -1}, +{ 1, 1, 1, -1, 1, -1, -1, -1}, +{ 1, 1, 1, -1, -1, 1, -1, -1}, +{ 1, 1, 1, -1, -1, -1, 1, -1}, +{ 1, 1, 1, -1, -1, -1, -1, 1}, +{ 1, 1, -1, 1, 1, -1, -1, -1}, +{ 1, 1, -1, 1, -1, 1, -1, -1}, +{ 1, 1, -1, 1, -1, -1, 1, -1}, +{ 1, 1, -1, 1, -1, -1, -1, 1}, +{ 1, 1, -1, -1, 1, 1, -1, -1}, +{ 1, 1, -1, -1, 1, -1, 1, -1}, +{ 1, 1, -1, -1, 1, -1, -1, 1}, +{ 1, 1, -1, -1, -1, -1, 1, 1}, +{ 1, 1, -1, -1, -1, 1, -1, 1}, +{ 1, 1, -1, -1, -1, 1, 1, -1}, +{ 1, -1, 1, 1, 1, -1, -1, -1}, +{ 1, -1, 1, 1, -1, 1, -1, -1}, +{ 1, -1, 1, 1, -1, -1, 1, -1}, +{ 1, -1, 1, 1, -1, -1, -1, 1}, +{ 1, -1, 1, -1, 1, 1, -1, -1}, +{ 1, -1, 1, -1, 1, -1, 1, -1}, +{ 1, -1, 1, -1, 1, -1, -1, 1}, +{ 1, -1, 1, -1, -1, -1, 1, 1}, +{ 1, -1, 1, -1, -1, 1, -1, 1}, +{ 1, -1, 1, -1, -1, 1, 1, -1}, +{ 1, -1, -1, -1, -1, 1, 1, 1}, +{ 1, -1, -1, -1, 1, -1, 1, 1}, +{ 1, -1, -1, -1, 1, 1, -1, 1}, +{ 1, -1, -1, -1, 1, 1, 1, -1}, +{ 1, -1, -1, 1, 1, 1, -1, -1}, +{ 1, -1, -1, 1, 1, -1, 1, -1}, +{ 1, -1, -1, 1, 1, -1, -1, 1}, +{ 1, -1, -1, 1, -1, -1, 1, 1}, +{ 1, -1, -1, 1, -1, 1, -1, 1}, +{ 1, -1, -1, 1, -1, 1, 1, -1}, +{ 1, 1, -1, -1, -1, -1, -1, -1}, +{ 1, -1, 1, -1, -1, -1, -1, -1}, +{ 1, -1, -1, 1, -1, -1, -1, -1}, +{ 1, -1, -1, -1, 1, -1, -1, -1}, +{ 1, -1, -1, -1, -1, 1, -1, -1}, +{ 1, -1, -1, -1, -1, -1, 1, -1}, +{ 1, -1, -1, -1, -1, -1, -1, 1}, +{-1, 1, 1, -1, -1, -1, -1, -1}, +{-1, 1, -1, 1, -1, -1, -1, -1}, +{-1, 1, -1, -1, 1, -1, -1, -1}, +{-1, 1, -1, -1, -1, 1, -1, -1}, +{-1, 1, -1, -1, -1, -1, 1, -1}, +{-1, 1, -1, -1, -1, -1, -1, 1}, +{-1, -1, 1, 1, -1, -1, -1, -1}, +{-1, -1, 1, -1, 1, -1, -1, -1}, +{-1, -1, 1, -1, -1, 1, -1, -1}, +{-1, -1, 1, -1, -1, -1, 1, -1}, +{-1, -1, 1, -1, -1, -1, -1, 1}, +{-1, -1, -1, 1, 1, -1, -1, -1}, +{-1, -1, -1, 1, -1, 1, -1, -1}, +{-1, -1, -1, 1, -1, -1, 1, -1}, +{-1, -1, -1, 1, -1, -1, -1, 1}, +{-1, -1, -1, -1, 1, 1, -1, -1}, +{-1, -1, -1, -1, 1, -1, 1, -1}, +{-1, -1, -1, -1, 1, -1, -1, 1}, +{-1, -1, -1, -1, -1, 1, 1, -1}, +{-1, -1, -1, -1, -1, 1, -1, 1}, +{-1, -1, -1, -1, -1, -1, 1, 1}, +{-1, -1, -1, -1, -1, -1, -1, -1}, +{ 1, 1, 1, 1, 1, 1, 1, 1} +}; + diff --git a/Frameworks/g719/g719/reference_code/decoder/dprocnf.c b/Frameworks/g719/g719/reference_code/decoder/dprocnf.c new file mode 100755 index 000000000..9e9198b8c --- /dev/null +++ b/Frameworks/g719/g719/reference_code/decoder/dprocnf.c @@ -0,0 +1,59 @@ +/*-----------------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*-----------------------------------------------------------------------------------*/ + +#include "proto.h" +#include "cnst.h" +#include "rom.h" + +/*---------------------------------------------------------------------------*/ +/* Function dprocnf */ +/* ~~~~~~~~~~~~~~~~~ */ +/* */ +/* De-quantization for sub-vectors originally allocated with 0 bits */ +/*---------------------------------------------------------------------------*/ +/* short *y (i) indices of the selected codevectors */ +/* short *pbits (i) pointer to bitstream */ +/* short idxnrm (i) indices of quantized norms */ +/* short nb_vecs (i) number of 8-D vectors in current sub-vector */ +/* float *coefs (o) MLT coefficients */ +/* float *coefs_norm (o) normalized MLT coefficients */ +/*---------------------------------------------------------------------------*/ +void dprocnf(short *y, short *pbits, short idxnrm, short nb_vecs, float *coefs, float* coefs_norm) +{ + short i, j; + short pre_idx; + float normq; + + + normq = dicn[idxnrm]; + pre_idx = MAX16B; + for (i=0; i0; i--) + { + if (R[idx[i]]==0) + { + im = i; + } + } + for (i=im; i=WID_G1) + { + R[m] = 1; + offset = m * WID_G1; + dprocnf(&ycof[offset], pbits, ynrm[m], NB_VECT1, &coefsq[offset], &coefsq_norm[offset]); + pbits += WID_G1; + diff -= WID_G1; + } + } + else if (m=WID_G2) + { + R[m] = 1; + offset = NUMC_G1 + (m - SFM_G1) * WID_G2; + dprocnf(&ycof[offset], pbits, ynrm[m], NB_VECT2, &coefsq[offset], &coefsq_norm[offset]); + pbits += WID_G2; + diff -= WID_G2; + } + } + else if (m=WID_G3) + { + R[m] = 1; + offset = NUMC_G1G2 + (m - SFM_G1G2) * WID_G3; + dprocnf(&ycof[offset], pbits, ynrm[m], NB_VECT3, &coefsq[offset], &coefsq_norm[offset]); + pbits += WID_G3; + diff -= WID_G3; + } + } + else + { + if (diff>=WID_GX) + { + R[m] = 1; + offset = NUMC_N + (m - SFM_N) * WID_GX; + dprocnf(&ycof[offset], pbits, ynrm[m], NB_VECTX, &coefsq[offset], &coefsq_norm[offset]); + pbits += WID_GX; + diff -= WID_GX; + } + } + } + } + + *ppbits = pbits; + return; +} diff --git a/Frameworks/g719/g719/reference_code/decoder/dqcoefs.c b/Frameworks/g719/g719/reference_code/decoder/dqcoefs.c new file mode 100755 index 000000000..8d1a93912 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/decoder/dqcoefs.c @@ -0,0 +1,104 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "proto.h" +#include "cnst.h" +#include "rom.h" + +/*--------------------------------------------------------------------------*/ +/* Function dqcoefs */ +/* ~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Vector de-quantization for normalized MLT coefficients */ +/*--------------------------------------------------------------------------*/ +/* short *y (i) indices of the selected codevectors */ +/* short *idxnrm (i) indices of quantized norms */ +/* short *R (i) number of bits per coefficient */ +/* short N1 (i) beginning sub-vector's number in the group */ +/* short N2 (i) ending sub-vector's number in the group */ +/* short L (i) number of coefficients in each sub-vector */ +/* float *coefs (o) MLT coefficients */ +/* float *coefs_norm (o) normalized MLT coefficients */ +/*--------------------------------------------------------------------------*/ +void dqcoefs(short *y, + short *idxnrm, + short *R, + short N1, + short N2, + short L, + float *coefs, + float *coefs_norm) +{ + short i, j, n, v, rv; + short nb_vecs, pre_idx; + short x[8]; + float normq, factor; + short *pidx; + float *pcoefs, *pcoefs_norm; + + + pidx = y; + pcoefs = coefs; + pcoefs_norm = coefs_norm; + nb_vecs = L >> 3; + for (n=N1; n1) + { + rv = RV[v]; + factor = FCT_LVQ2f / (float)rv; + for (i=0; i + +/*--------------------------------------------------------------------------*/ +/* Function fill_spectrum */ +/* ~~~~~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Fill the spectrum which has been quantized with 0 bits */ +/*--------------------------------------------------------------------------*/ +/* float *coeff (i) normalized MLT coefficients */ +/* float *coeff_out (o) MLT coefficients */ +/* short *R (i) number of bits per coefficient */ +/* short is_transient (i) transient flag */ +/* short norm (i) quantization indices for norms */ +/* short nf_idx (i) noise fill index */ +/*--------------------------------------------------------------------------*/ +void fill_spectrum(float *coeff, + float *coeff_out, + short *R, + short is_transient, + short norm[], + short nf_idx) +{ + float CodeBook[FREQ_LENGTH]; + float *src, *dst, *end; + float normq; + short cb_size, cb_pos; + short sfm, j, i; + + short last_sfm; + short first_coeff; + short low_coeff; + + /* Build codebook */ + cb_size = 0; + for (sfm = 0; sfm < NB_SFM; sfm++) + { + if (R[sfm] != 0) + { + for (j = sfm_start[sfm]; j < sfm_end[sfm]; j++) + { + CodeBook[cb_size] = coeff[j]; + cb_size++; + } + } + } + + /* detect last sfm */ + last_sfm = NB_SFM - 1; + if (is_transient == 0) + { + for (sfm = NB_SFM-1; sfm >= 0; sfm--) + { + if (R[sfm] != 0) + { + last_sfm = sfm; + break; + } + } + } + + if (cb_size != 0) + { + /* Read from codebook */ + cb_pos = 0; + for (sfm = 0; sfm <= last_sfm; sfm++) + { + if (R[sfm] == 0) + { + for (j = sfm_start[sfm]; j < sfm_end[sfm]; j++) + { + coeff[j] = CodeBook[cb_pos]; + cb_pos++; + cb_pos = (cb_pos>=cb_size) ? 0 : cb_pos; + } + } + } + + if (is_transient == 0) + { + low_coeff = sfm_end[last_sfm] >> 1; + src = coeff + sfm_end[last_sfm] - 1; + + first_coeff = sfm_end[last_sfm]; + dst = coeff + sfm_end[last_sfm]; + end = coeff + sfm_end[NB_SFM-1]; + + while (dst < end) + { + while (dst < end && src >= &coeff[low_coeff]) + { + *dst++ = *src--; + } + + src++; + + while (dst < end && src < &coeff[first_coeff]) + { + *dst++ = *src++; + } + } + } + + for (sfm = 0; sfm <= last_sfm; sfm++) + { + if (R[sfm] == 0) + { + for (j = sfm_start[sfm]; j < sfm_end[sfm]; j++) + { + /* Scale NoiseFill */ + coeff[j] = (float)(coeff[j]/pow(2,nf_idx)); + } + } + } + } + + /* shape the spectrum */ + for (sfm = 0; sfm < NB_SFM; sfm++) + { + normq = dicn[norm[sfm]]; + for (i = sfm_start[sfm]; i < sfm_end[sfm]; i++) + { + coeff_out[i] = coeff[i]*normq; + } + } +} diff --git a/Frameworks/g719/g719/reference_code/decoder/flvqdec.c b/Frameworks/g719/g719/reference_code/decoder/flvqdec.c new file mode 100755 index 000000000..aaab23c4b --- /dev/null +++ b/Frameworks/g719/g719/reference_code/decoder/flvqdec.c @@ -0,0 +1,180 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "proto.h" +#include "cnst.h" +#include "rom.h" + +/*--------------------------------------------------------------------------*/ +/* Function flvqdec */ +/* ~~~~~~~~~~~~~~~~~ */ +/* */ +/* Decoding of Fast Lattice Vector Quantization (FLVQ) */ +/*--------------------------------------------------------------------------*/ +/* short **bitstream (i) bit-stream vector */ +/* float *coefsq (o) MLT coefficient vector */ +/* float *coefsq_norm (o) normalized MLT coefficient vector */ +/* short R (o) bit-allocation vector */ +/* short NumSpectumBits (i) number of available bits */ +/* short *ynrm (o) norm quantization index vector */ +/* short is_transient (i) transient flag */ +/*--------------------------------------------------------------------------*/ +void flvqdec( + short **bitstream, + float *coefsq, + float *coefsq_norm, + short *R, + short NumSpectumBits, + short *ynrm, + short is_transient +) +{ + short i, j, k, v, nb_sfm; + short diff; + short hcode_l, FlagL, FlagN, FlagC; + short idx[NB_SFM], normqlg2[NB_SFM], wnorm[NB_SFM], idxbuf[NB_SFM]; + short ycof[STOP_BAND]; + short *pbits; + short **ppbits; + + + pbits = *bitstream; + /*** Unpacking bit stream to flags ***/ + FlagL = 0; + if ((*pbits++)==G192_BIT1) + { + FlagL = 1; + } + FlagN = 0; + if ((*pbits++)==G192_BIT1) + { + FlagN = 1; + } + FlagC = 0; + if ((*pbits++)==G192_BIT1) + { + FlagC = 1; + } + + /*** Unpacking bit stream and Huffman decoding for indices of quantized norms ***/ + if (FlagL==NOALLGROUPS) + { + nb_sfm = SFM_N; + } + else + { + nb_sfm = NB_SFM; + } + bits2idxn(pbits, NORM0_BITS, ynrm); + pbits += NORM0_BITS; + if (FlagN==HUFCODE) + { + hdecnrm(pbits, NB_SFM, &ynrm[1]); + hcode_l = 0; + for (i=1; iSFM_N) + { + k = unpackc(R, pbits, FlagC, NUMC_N, SFM_N, NB_SFM, WID_GX, ycof); + pbits += k; + hcode_l += k; + } + diff = v - hcode_l; + + + /*** Lattice Vector De-quantization for normalized MLT coefficients ***/ + /* First group */ + dqcoefs(&ycof[0], ynrm, R, 0, SFM_G1, WID_G1, &coefsq[0], &coefsq_norm[0]); + + /* Second group */ + dqcoefs(&ycof[NUMC_G1], ynrm, R, SFM_G1, SFM_G1G2, WID_G2, &coefsq[NUMC_G1], &coefsq_norm[NUMC_G1]); + + /* Third group */ + dqcoefs(&ycof[NUMC_G1G2], ynrm, R, SFM_G1G2, SFM_N, WID_G3, &coefsq[NUMC_G1G2], &coefsq_norm[NUMC_G1G2]); + + /* Forth group */ + dqcoefs(&ycof[NUMC_N], ynrm, R, SFM_N, NB_SFM, WID_GX, &coefsq[NUMC_N], &coefsq_norm[NUMC_N]); + + + /*** Processing for noise-filling sub-vectors ***/ + ppbits = &pbits; + dprocnobitsbfm(R, idx, ynrm, ycof, ppbits, coefsq, coefsq_norm, nb_sfm, diff); + + *bitstream = pbits; + return; +} diff --git a/Frameworks/g719/g719/reference_code/decoder/hdeclvq.c b/Frameworks/g719/g719/reference_code/decoder/hdeclvq.c new file mode 100755 index 000000000..d38381ce0 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/decoder/hdeclvq.c @@ -0,0 +1,305 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#include "cnst.h" + +/*--------------------------------------------------------------------------*/ +/* Function hdec2blvq */ +/* ~~~~~~~~~~~~~~~~~~~ */ +/* */ +/* Huffman decoding for LVQ2 quantization indices */ +/*--------------------------------------------------------------------------*/ +/* short *bitstream (i) Huffman code */ +/* short N (i) number of coefficients */ +/* short *index (o) LVQ2 quantization indices */ +/*--------------------------------------------------------------------------*/ +void hdec2blvq(short *bitstream, short N, short *index) +{ + short i; + short temp; + short *pbits, *pidx; + + + pbits = bitstream; + pidx = index; + + for (i=0; i> 3; + length = 0; + if (flag==NOHUFCODE) + { + for (n=N1; n1) + { + bits2idxc(pbits, L, v, &y[rv]); + sum = v * L; + pbits += sum; + length += sum; + } + else if (v==1) + { + k = rv; + for (i=0; iQBIT_MAX1) + { + bits2idxc(pbits, L, v, &y[rv]); + sum = v * L; + pbits += sum; + r += sum; + } + else if (v>1) + { + if (v==2) + { + hdec2blvq(pbits, L, &y[rv]); + } + else if (v==3) + { + hdec3blvq(pbits, L, &y[rv]); + } + else if (v==4) + { + hdec4blvq(pbits, L, &y[rv]); + } + else + { + hdec5blvq(pbits, L, &y[rv]); + } + offset = huffoffset[v]; + for (i=0; i 32767.0f) + { + OutputVal = 32767.0f; + } + else if (OutputVal < -32768.0f) + { + OutputVal = -32768.0f; + } + auOut[i] = (short)OutputVal; + } + + for (i=0 ; i < FRAME_LENGTH ; i++) + { + OldauOut[i] = ImdctOutWin[i+FRAME_LENGTH]; + } +} diff --git a/Frameworks/g719/g719/reference_code/include/cnst.h b/Frameworks/g719/g719/reference_code/include/cnst.h new file mode 100755 index 000000000..1789d809d --- /dev/null +++ b/Frameworks/g719/g719/reference_code/include/cnst.h @@ -0,0 +1,88 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#ifndef _CNST_H +#define _CNST_H + + +#define CODEC_VERSION "0.5b" + +#define MAX16B (short)0x7fff +#define MIN16B (short)0x8000 +#define EPSILON 0.000000000000001f +#define PI 3.141592653589793238462f +#define TRUE 1 +#define FALSE 0 + +#define FRAME_LENGTH 960 +#define MAX_SEGMENT_LENGTH 480 +#define MAX_BITS_PER_FRAME 2560 +#define NUM_TIME_SWITCHING_BLOCKS 4 +#define NUM_MAP_BANDS 20 +#define FREQ_LENGTH 800 + +#define G192_SYNC_GOOD_FRAME (unsigned short) 0x6B21 +#define G192_SYNC_BAD_FRAME (unsigned short) 0x6B20 +#define G192_BIT0 (unsigned short) 0x007F +#define G192_BIT1 (unsigned short) 0x0081 + +#define MLT960_LENGTH 960 +#define MLT960_LENGTH_DIV_2 480 +#define MLT960_LENGTH_MINUS_1 959 +#define MLT240_LENGTH 240 +#define MLT240_LENGTH_MINUS_1 239 + +#define STOP_BAND 800 +#define STOP_BAND4 200 + +#define SFM_G1 16 +#define SFM_G2 8 +#define SFM_G1G2 24 +#define SFM_G3 12 +#define SFM_N 36 +#define SFM_GX 8 +#define NB_SFM 44 +#define WID_G1 8 +#define WID_G2 16 +#define WID_G3 24 +#define WID_GX 32 +#define NUMC_G1 128 +#define NUMC_G1G2 256 +#define NUMC_N 544 +#define NB_VECT1 1 +#define NB_VECT2 2 +#define NB_VECT3 3 +#define NB_VECTX 4 + +#define NUMC_G23 256 +#define NUMC_G1SUB 32 +#define NUMC_G1G2SUB 64 +#define NUMC_G1G2G3SUB 136 + +#define QBIT_MAX1 5 +#define QBIT_MAX2 9 +#define OFFSETf 0.015625f +#define FCT_LVQ1f 1.1f +#define FCT_LVQ2f 6.0f +#define FCT_LVQ2fQ13 1365.333333f +#define MAX_DIST 100000000.0f +#define N_LEADER1 10 + +#define FLAGS_BITS 3 +#define NORM0_BITS 5 +#define NORMI_BITS 5 +#define NUMNRMIBITS 215 + +#define NOALLGROUPS 0 +#define ALLGROUPS 1 + +#define NOHUFCODE 0 +#define HUFCODE 1 + + +#include "rom.h" +#endif + diff --git a/Frameworks/g719/g719/reference_code/include/complxop.h b/Frameworks/g719/g719/reference_code/include/complxop.h new file mode 100755 index 000000000..ba713f7c7 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/include/complxop.h @@ -0,0 +1,25 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#ifndef _COMPLXOP_H +#define _COMPLXOP_H + +/******************************************************************************* +/* Local type definitions +/******************************************************************************/ + +typedef struct complex_struct +{ + float r; + float i; +} complex; + +void cadd(complex var1, complex var2, complex *res); +void csub(complex var1, complex var2, complex *res); +void cmpys(complex var1, float var2, complex *res); +void cmpyj(complex* v1); + +#endif diff --git a/Frameworks/g719/g719/reference_code/include/proto.h b/Frameworks/g719/g719/reference_code/include/proto.h new file mode 100755 index 000000000..2382268e6 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/include/proto.h @@ -0,0 +1,359 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#ifndef _PROTO_H +#define _PROTO_H + +#include "cnst.h" +#include "state.h" + +void encoder_init( + CoderState *c, + short num_bits +); + +void encode_frame( + float *audio, + short *BitStream, + CoderState *c +); + +short detect_transient( + float in[], + CoderState *c +); + +void wtda( + float new_audio[], + float wtda_audio[], + float old_wtda[] +); + +void direct_transform( + float *in32, + float *out32, + short is_transient + ); + +short noise_adjust( + float *coeffs_norm, + short *bitalloc +); + +void interleave_spectrum( + float *coefs +); + +void flvqenc( + short **bitstream, + float *coefs, + float *coefs_norm, + short *R, + short NumSpectumBits, + short total_bits, + short is_transient +); + +void logqnorm( + float *x, + short *k, + short L, + short N +); + +void reordernorm( + short *ynrm, + short *normqlg2, + short *idxbuf, + short *normbuf +); + +void diffcod( + short *normqlg2, + short N, + short *y, + short *difidx +); + +void normalizecoefs( + float *coefs, + short *ynrm, + short N1, + short N2, + short L, + float *coefs_norm +); + +void bitallocsum( + short *R, + short nb_sfm, + short *sum +); + +void qcoefs( + float *coefs, + short *R, + short N1, + short N2, + short L, + short *y +); + +void lvq1( + float *x, + short *k +); + +void lvq2( + short *x, + short *k, + short r, + short R +); + +void code2idx( + short *x, + short *k, + short r +); + +short huffcheck( + short *y, + short *R, + short N1, + short N2, + short L +); + +short packingc( + short *y, + short *R, + short *pbits, + short flag, + short N1, + short N2, + short L +); + +void procnobitsbfm( + float *coefs_norm, + short *R, + short *idx, + short *ycof, + short **ppbits, + short nb_sfm, + short diff +); + +void procnf( + float *coefs, + short *y, + short *pbits, + short nb_vecs +); + +void idx2bitsn( + short x, + short N, + short *y +); + +void idx2bitsc( + short *x, + short N, + short L, + short *y +); + +void decoder_init( + DecoderState *d, + short num_bits +); + +void decoder_reset_tables( + DecoderState *d, + short num_bits +); + +void decode_frame( + short bitstream[], + short bfi, + short out16[], + DecoderState *d +); + +void flvqdec( + short **bitstream, + float *coefsq, + float *coefsq_norm, + short *R, + short NumSpectumBits, + short *ynrm, + short is_transient +); + +void hdecnrm( + short *bitstream, + short N, + short *index +); + +void hdec2blvq( + short *bitstream, + short N, + short *index +); + +void hdec3blvq( + short *bitstream, + short N, + short *index +); + +void hdec4blvq( + short *bitstream, + short N, + short *index +); + +void hdec5blvq( + short *bitstream, + short N, + short *index +); + +short unpackc( + short *R, + short *pbits, + short flag, + short rv, + short N1, + short N2, + short L, + short *y +); + +void dqcoefs( + short *y, + short *idxnrm, + short *R, + short N1, + short N2, + short L, + float *coefs, + float *coefs_norm +); + +void dprocnobitsbfm( + short *R, + short *idx, + short *ynrm, + short *ycof, + short **ppbits, + float *coefsq, + float *coefsq_norm, + short nb_sfm, + short diff +); + +void dprocnf( + short *y, + short *pbits, + short idxnrm, + short nb_vecs, + float *coefs, + float* coefs_norm +); + + +void fill_spectrum( + float *coeff, + float *coeff_out, + short *R, + short is_transient, + short norm[], + short nf_idx +); + +void de_interleave_spectrum( + float *coefs +); + +void inverse_transform( + float *InMDCT, + float *Out, + int IsTransient +); + +void window_ola( + float ImdctOut[], + short auOut[], + float OldauOut[] +); + +void bits2idxn( + short *y, + short N, + short *x +); + +void bits2idxc( + short *y, + short N, + short L, + short *x +); + +void dct4_960( + float v[MLT960_LENGTH], + float coefs32[MLT960_LENGTH] +); + +void dct4_240( + float v[], + float coefs32[] +); + +void map_quant_weight( + short normqlg2[], + short wnorm[], + short is_transient +); + +void recovernorm( + short *idxbuf, + short *ynrm, + short *normqlg2 +); + +void reordvct( + short *y, + short N, + short *idx +); + +void bitalloc( + short *y, + short *idx, + short sum, + short N, + short M, + short *r +); + +void codesearch( + short *x, + short *C, + short R +); + +void idx2code( + short *k, + short *y, + short R +); + +#endif diff --git a/Frameworks/g719/g719/reference_code/include/rom.h b/Frameworks/g719/g719/reference_code/include/rom.h new file mode 100755 index 000000000..cd0bb94e1 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/include/rom.h @@ -0,0 +1,53 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#ifndef _ROM_H +#define _ROM_H + +#include "complxop.h" + +extern float fft120cnst[144]; +extern complex ptwdf[480]; +extern complex dct480_table_1[480]; +extern complex dct480_table_2[480]; +extern complex dct120_table_1[120]; +extern complex dct120_table_2[120]; +extern int indxPre[120]; +extern int indxPost[120]; +extern float wscw16q15[]; + +extern short sfm_start[44]; +extern short sfm_end[44]; +extern short sfmsize[44]; + +extern float short_window[480]; +extern float window[1920]; + +extern float dicn[40]; +extern float thren[39]; +extern short dicnlg2[40]; + +extern short RV[10]; +extern short FacLVQ2Qv[10]; +extern short FacLVQ2Mask[10]; +extern short FacLVQ2HalfQv[10]; + +extern short dic0[10][8]; +extern short dic1[10][8]; +extern short dic2[10]; +extern short dic3[256]; +extern short dic4[256][8]; + +extern short huffnorm[32]; +extern short huffsizn[32]; +extern short huffcoef[60]; +extern short huffsizc[60]; +extern short huffoffset[6]; + +extern short sfm_width[20]; +extern short a[20]; + +#endif diff --git a/Frameworks/g719/g719/reference_code/include/state.h b/Frameworks/g719/g719/reference_code/include/state.h new file mode 100755 index 000000000..1e8e3e1d5 --- /dev/null +++ b/Frameworks/g719/g719/reference_code/include/state.h @@ -0,0 +1,38 @@ +/*--------------------------------------------------------------------------*/ +/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */ +/* © 2008 Ericsson AB. and Polycom Inc. */ +/* All rights reserved. */ +/*--------------------------------------------------------------------------*/ + +#ifndef _STATE_H +#define _STATE_H + +#include +#include "cnst.h" + +typedef struct +{ + float old_wtda[FRAME_LENGTH/2]; + float old_hpfilt_in; + float old_hpfilt_out; + float EnergyLT; + + short TransientHangOver; + + short num_bits; + short num_bits_spectrum_stationary ; + short num_bits_spectrum_transient ; +} CoderState; + +typedef struct { + float old_out[FRAME_LENGTH]; + float old_coeffs[FRAME_LENGTH]; + + short num_bits; + short num_bits_spectrum_stationary; + short num_bits_spectrum_transient; + + short old_is_transient; +} DecoderState; + +#endif diff --git a/Frameworks/g719/g719/stack_alloc.h b/Frameworks/g719/g719/stack_alloc.h new file mode 100644 index 000000000..17c85383c --- /dev/null +++ b/Frameworks/g719/g719/stack_alloc.h @@ -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 +# else +# ifdef HAVE_ALLOCA_H +# include +# else +# include +# 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 */ diff --git a/Frameworks/g7221/g7221.xcodeproj/project.pbxproj b/Frameworks/g7221/g7221.xcodeproj/project.pbxproj new file mode 100644 index 000000000..1258ec43b --- /dev/null +++ b/Frameworks/g7221/g7221.xcodeproj/project.pbxproj @@ -0,0 +1,345 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 83D730FF1A738F4E00CA1366 /* common.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D730F21A738F4E00CA1366 /* common.c */; }; + 83D731001A738F4E00CA1366 /* common.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D730F31A738F4E00CA1366 /* common.h */; }; + 83D731011A738F4E00CA1366 /* dct4.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D730F41A738F4E00CA1366 /* dct4.c */; }; + 83D731021A738F4E00CA1366 /* dct4.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D730F51A738F4E00CA1366 /* dct4.h */; }; + 83D731031A738F4E00CA1366 /* decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D730F61A738F4E00CA1366 /* decoder.c */; }; + 83D731041A738F4E00CA1366 /* decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D730F71A738F4E00CA1366 /* decoder.h */; }; + 83D731051A738F4E00CA1366 /* huffman.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D730F81A738F4E00CA1366 /* huffman.c */; }; + 83D731061A738F4E00CA1366 /* huffman.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D730F91A738F4E00CA1366 /* huffman.h */; }; + 83D731071A738F4E00CA1366 /* huffman_consts.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D730FA1A738F4E00CA1366 /* huffman_consts.h */; }; + 83D731081A738F4E00CA1366 /* rmlt.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D730FB1A738F4E00CA1366 /* rmlt.c */; }; + 83D731091A738F4E00CA1366 /* rmlt.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D730FC1A738F4E00CA1366 /* rmlt.h */; }; + 83D7310A1A738F4E00CA1366 /* siren7.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D730FD1A738F4E00CA1366 /* siren7.h */; }; + 83D7310B1A738F4E00CA1366 /* g7221.h in Headers */ = {isa = PBXBuildFile; fileRef = 83D730FE1A738F4E00CA1366 /* g7221.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 83D7310D1A738F8500CA1366 /* g7221.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7310C1A738F8500CA1366 /* g7221.c */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 83D730C91A738EB200CA1366 /* g7221.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = g7221.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 83D730CD1A738EB200CA1366 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 83D730F21A738F4E00CA1366 /* common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = common.c; sourceTree = ""; }; + 83D730F31A738F4E00CA1366 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = ""; }; + 83D730F41A738F4E00CA1366 /* dct4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dct4.c; sourceTree = ""; }; + 83D730F51A738F4E00CA1366 /* dct4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dct4.h; sourceTree = ""; }; + 83D730F61A738F4E00CA1366 /* decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = decoder.c; sourceTree = ""; }; + 83D730F71A738F4E00CA1366 /* decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decoder.h; sourceTree = ""; }; + 83D730F81A738F4E00CA1366 /* huffman.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = huffman.c; sourceTree = ""; }; + 83D730F91A738F4E00CA1366 /* huffman.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = huffman.h; sourceTree = ""; }; + 83D730FA1A738F4E00CA1366 /* huffman_consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = huffman_consts.h; sourceTree = ""; }; + 83D730FB1A738F4E00CA1366 /* rmlt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rmlt.c; sourceTree = ""; }; + 83D730FC1A738F4E00CA1366 /* rmlt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rmlt.h; sourceTree = ""; }; + 83D730FD1A738F4E00CA1366 /* siren7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = siren7.h; sourceTree = ""; }; + 83D730FE1A738F4E00CA1366 /* g7221.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = g7221.h; sourceTree = ""; }; + 83D7310C1A738F8500CA1366 /* g7221.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g7221.c; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 83D730C51A738EB200CA1366 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 83D730BF1A738EB200CA1366 = { + isa = PBXGroup; + children = ( + 83D730CB1A738EB200CA1366 /* g7221 */, + 83D730CA1A738EB200CA1366 /* Products */, + ); + sourceTree = ""; + }; + 83D730CA1A738EB200CA1366 /* Products */ = { + isa = PBXGroup; + children = ( + 83D730C91A738EB200CA1366 /* g7221.framework */, + ); + name = Products; + sourceTree = ""; + }; + 83D730CB1A738EB200CA1366 /* g7221 */ = { + isa = PBXGroup; + children = ( + 83D730F11A738F4E00CA1366 /* libsiren */, + 83D730FE1A738F4E00CA1366 /* g7221.h */, + 83D730CC1A738EB200CA1366 /* Supporting Files */, + 83D7310C1A738F8500CA1366 /* g7221.c */, + ); + path = g7221; + sourceTree = ""; + }; + 83D730CC1A738EB200CA1366 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 83D730CD1A738EB200CA1366 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 83D730F11A738F4E00CA1366 /* libsiren */ = { + isa = PBXGroup; + children = ( + 83D730F21A738F4E00CA1366 /* common.c */, + 83D730F31A738F4E00CA1366 /* common.h */, + 83D730F41A738F4E00CA1366 /* dct4.c */, + 83D730F51A738F4E00CA1366 /* dct4.h */, + 83D730F61A738F4E00CA1366 /* decoder.c */, + 83D730F71A738F4E00CA1366 /* decoder.h */, + 83D730F81A738F4E00CA1366 /* huffman.c */, + 83D730F91A738F4E00CA1366 /* huffman.h */, + 83D730FA1A738F4E00CA1366 /* huffman_consts.h */, + 83D730FB1A738F4E00CA1366 /* rmlt.c */, + 83D730FC1A738F4E00CA1366 /* rmlt.h */, + 83D730FD1A738F4E00CA1366 /* siren7.h */, + ); + path = libsiren; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 83D730C61A738EB200CA1366 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 83D7310B1A738F4E00CA1366 /* g7221.h in Headers */, + 83D731061A738F4E00CA1366 /* huffman.h in Headers */, + 83D7310A1A738F4E00CA1366 /* siren7.h in Headers */, + 83D731071A738F4E00CA1366 /* huffman_consts.h in Headers */, + 83D731001A738F4E00CA1366 /* common.h in Headers */, + 83D731041A738F4E00CA1366 /* decoder.h in Headers */, + 83D731021A738F4E00CA1366 /* dct4.h in Headers */, + 83D731091A738F4E00CA1366 /* rmlt.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 83D730C81A738EB200CA1366 /* g7221 */ = { + isa = PBXNativeTarget; + buildConfigurationList = 83D730DF1A738EB200CA1366 /* Build configuration list for PBXNativeTarget "g7221" */; + buildPhases = ( + 83D730C41A738EB200CA1366 /* Sources */, + 83D730C51A738EB200CA1366 /* Frameworks */, + 83D730C61A738EB200CA1366 /* Headers */, + 83D730C71A738EB200CA1366 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = g7221; + productName = g7221; + productReference = 83D730C91A738EB200CA1366 /* g7221.framework */; + productType = "com.apple.product-type.framework"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 83D730C01A738EB200CA1366 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0610; + ORGANIZATIONNAME = "Christopher Snowhill"; + TargetAttributes = { + 83D730C81A738EB200CA1366 = { + CreatedOnToolsVersion = 6.1.1; + }; + }; + }; + buildConfigurationList = 83D730C31A738EB200CA1366 /* Build configuration list for PBXProject "g7221" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 83D730BF1A738EB200CA1366; + productRefGroup = 83D730CA1A738EB200CA1366 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 83D730C81A738EB200CA1366 /* g7221 */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 83D730C71A738EB200CA1366 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 83D730C41A738EB200CA1366 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 83D731081A738F4E00CA1366 /* rmlt.c in Sources */, + 83D731011A738F4E00CA1366 /* dct4.c in Sources */, + 83D731031A738F4E00CA1366 /* decoder.c in Sources */, + 83D7310D1A738F8500CA1366 /* g7221.c in Sources */, + 83D730FF1A738F4E00CA1366 /* common.c in Sources */, + 83D731051A738F4E00CA1366 /* huffman.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 83D730DD1A738EB200CA1366 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 83D730DE1A738EB200CA1366 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 83D730E01A738EB200CA1366 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = g7221/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 83D730E11A738EB200CA1366 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COMBINE_HIDPI_IMAGES = YES; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + FRAMEWORK_VERSION = A; + INFOPLIST_FILE = g7221/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 83D730C31A738EB200CA1366 /* Build configuration list for PBXProject "g7221" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83D730DD1A738EB200CA1366 /* Debug */, + 83D730DE1A738EB200CA1366 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 83D730DF1A738EB200CA1366 /* Build configuration list for PBXNativeTarget "g7221" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 83D730E01A738EB200CA1366 /* Debug */, + 83D730E11A738EB200CA1366 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 83D730C01A738EB200CA1366 /* Project object */; +} diff --git a/Frameworks/g7221/g7221/Info.plist b/Frameworks/g7221/g7221/Info.plist new file mode 100644 index 000000000..79dc551e1 --- /dev/null +++ b/Frameworks/g7221/g7221/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + org.cogx.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSHumanReadableCopyright + Copyright © 2015 Christopher Snowhill. All rights reserved. + NSPrincipalClass + + + diff --git a/Frameworks/g7221/g7221/g7221.c b/Frameworks/g7221/g7221/g7221.c new file mode 100644 index 000000000..2b7c1ef1f --- /dev/null +++ b/Frameworks/g7221/g7221/g7221.c @@ -0,0 +1,43 @@ +// +// g7221.c +// g7221 +// +// Created by Christopher Snowhill on 1/24/15. +// Copyright (c) 2015 Christopher Snowhill. All rights reserved. +// + +#include "g7221.h" + +#include "libsiren/siren7.h" + +g7221_handle * g7221_init(int bytes_per_frame, int bandwidth) +{ + g7221_handle * handle = 0; + int sample_rate = bytes_per_frame * 8 * 50; + if ( sample_rate >= 16000 && sample_rate <= 48000 ) + { + if ( ( ( sample_rate / 800 ) * 800 ) == sample_rate ) + { + if ( bandwidth == 7000 || bandwidth == 14000 ) + { + handle = (g7221_handle *) Siren7_NewDecoder( sample_rate, ( bandwidth == 7000 ) ? 1 : 2 ); + } + } + } + return handle; +} + +void g7221_decode_frame(g7221_handle *handle, void *code_words, void *sample_buffer) +{ + Siren7_DecodeFrame((SirenDecoder)handle, (unsigned char *)code_words, (unsigned char *)sample_buffer); +} + +void g7221_reset(g7221_handle *handle) +{ + Siren7_ResetDecoder ((SirenDecoder)handle); +} + +void g7221_free(g7221_handle *handle) +{ + Siren7_CloseDecoder((SirenDecoder) handle); +} diff --git a/Frameworks/g7221/g7221/g7221.h b/Frameworks/g7221/g7221/g7221.h new file mode 100755 index 000000000..f116fd417 --- /dev/null +++ b/Frameworks/g7221/g7221/g7221.h @@ -0,0 +1,23 @@ +/* + Interface to reference G.722.1 decoder +*/ + +#ifndef G7221_H +#define G7221_H + +/* forward definition for the opaque handle object */ +typedef struct g7221_handle_s g7221_handle; + +/* return a handle for decoding on successful init, NULL on failure */ +g7221_handle * g7221_init(int bytes_per_frame, int bandwidth); + +/* decode a frame, at code_words, into 16-bit PCM in sample_buffer */ +void g7221_decode_frame(g7221_handle *handle, void *code_words, void *sample_buffer); + +/* reset the decoder to its initial state */ +void g7221_reset(g7221_handle *handle); + +/* free resources */ +void g7221_free(g7221_handle *handle); + +#endif diff --git a/Frameworks/g7221/g7221/libsiren/common.c b/Frameworks/g7221/g7221/libsiren/common.c new file mode 100644 index 000000000..cb5c9e50a --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/common.c @@ -0,0 +1,529 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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 "siren7.h" + +int region_size; +float region_size_inverse; + +float standard_deviation[64]; +float deviation_inverse[64]; +float region_power_table_boundary[63]; + +int expected_bits_table[8] = { 52, 47, 43, 37, 29, 22, 16, 0 }; +int vector_dimension[8] = { 2, 2, 2, 4, 4, 5, 5, 1 }; +int number_of_vectors[8] = { 10, 10, 10, 5, 5, 4, 4, 20 }; +float dead_zone[8] = { 0.3f, 0.33f, 0.36f, 0.39f, 0.42f, 0.45f, 0.5f, 0.5f }; + +int max_bin[8] = { + 13, + 9, + 6, + 4, + 3, + 2, + 1, + 1 +}; + +float step_size[8] = { + 0.3536f, + 0.5f, + 0.70709997f, + 1.0f, + 1.4141999f, + 2.0f, + 2.8283999f, + 2.8283999f +}; + +float step_size_inverse[8]; + +static int siren_initialized = 0; + +/* + STEPSIZE = 2.0 * log(sqrt(2)); +*/ +#define STEPSIZE 0.3010299957 + +void +siren_init (void) +{ + int i; + float region_power; + + if (siren_initialized == 1) + return; + + region_size = 20; + region_size_inverse = 1.0f / region_size; + + for (i = 0; i < 64; i++) { + region_power = (float) pow (10, (i - 24) * STEPSIZE); + standard_deviation[i] = (float) sqrt (region_power); + deviation_inverse[i] = (float) 1.0 / standard_deviation[i]; + } + + for (i = 0; i < 63; i++) + region_power_table_boundary[i] = + (float) pow (10, (i - 24 + 0.5) * STEPSIZE); + + for (i = 0; i < 8; i++) + step_size_inverse[i] = (float) 1.0 / step_size[i]; + + siren_dct4_init (); + siren_rmlt_init (); + + siren_initialized = 1; +} + + +int +categorize_regions (int number_of_regions, int number_of_available_bits, + int *absolute_region_power_index, int *power_categories, + int *category_balance) +{ + int region, delta, i, temp; + int expected_number_of_code_bits; + int min, max; + int offset, + num_rate_control_possibilities, + raw_value, raw_max_idx = 0, raw_min_idx = 0; + int max_rate_categories[28]; + int min_rate_categories[28]; + int temp_category_balances[64]; + int *min_rate_ptr = NULL; + int *max_rate_ptr = NULL; + + if (number_of_regions == 14) { + num_rate_control_possibilities = 16; + if (number_of_available_bits > 320) + number_of_available_bits = + ((number_of_available_bits - 320) * 5 / 8) + 320; + } else { + num_rate_control_possibilities = 32; + if (number_of_regions == 28 && number_of_available_bits > 640) + number_of_available_bits = + ((number_of_available_bits - 640) * 5 / 8) + 640; + } + + offset = -32; + for (delta = 32; number_of_regions > 0 && delta > 0; delta /= 2) { + expected_number_of_code_bits = 0; + for (region = 0; region < number_of_regions; region++) { + i = (delta + offset - absolute_region_power_index[region]) >> 1; + if (i > 7) + i = 7; + else if (i < 0) + i = 0; + + power_categories[region] = i; + expected_number_of_code_bits += expected_bits_table[i]; + + } + if (expected_number_of_code_bits >= number_of_available_bits - 32) + offset += delta; + } + + expected_number_of_code_bits = 0; + for (region = 0; region < number_of_regions; region++) { + i = (offset - absolute_region_power_index[region]) >> 1; + if (i > 7) + i = 7; + else if (i < 0) + i = 0; + max_rate_categories[region] = min_rate_categories[region] = + power_categories[region] = i; + expected_number_of_code_bits += expected_bits_table[i]; + } + + + min = max = expected_number_of_code_bits; + min_rate_ptr = max_rate_ptr = + temp_category_balances + num_rate_control_possibilities; + for (i = 0; i < num_rate_control_possibilities - 1; i++) { + if (min + max > number_of_available_bits * 2) { + raw_value = -99; + for (region = number_of_regions - 1; region >= 0; region--) { + if (min_rate_categories[region] < 7) { + temp = + offset - absolute_region_power_index[region] - + 2 * min_rate_categories[region]; + if (temp > raw_value) { + raw_value = temp; + raw_min_idx = region; + } + } + } + *min_rate_ptr++ = raw_min_idx; + min += + expected_bits_table[min_rate_categories[raw_min_idx] + 1] - + expected_bits_table[min_rate_categories[raw_min_idx]]; + min_rate_categories[raw_min_idx]++; + } else { + raw_value = 99; + for (region = 0; region < number_of_regions; region++) { + if (max_rate_categories[region] > 0) { + temp = + offset - absolute_region_power_index[region] - + 2 * max_rate_categories[region]; + if (temp < raw_value) { + raw_value = temp; + raw_max_idx = region; + } + } + } + + *--max_rate_ptr = raw_max_idx; + max += + expected_bits_table[max_rate_categories[raw_max_idx] - 1] - + expected_bits_table[max_rate_categories[raw_max_idx]]; + max_rate_categories[raw_max_idx]--; + } + } + + for (region = 0; region < number_of_regions; region++) + power_categories[region] = max_rate_categories[region]; + + for (i = 0; i < num_rate_control_possibilities - 1; i++) + category_balance[i] = *max_rate_ptr++; + + + return 0; +} + + + +/* + Looks like the flag means what kind of encoding is used + for now, it looks like : + 0 : the sample rate is not encoded in the frame + 1 - 2 : the sample rate is fixed in the frame + 3 : sample rate is variable and there is one for each frame +*/ + +int +GetSirenCodecInfo (int flag, int sample_rate, int *number_of_coefs, + int *sample_rate_bits, int *rate_control_bits, + int *rate_control_possibilities, int *checksum_bits, int *esf_adjustment, + int *scale_factor, int *number_of_regions, int *sample_rate_code, + int *bits_per_frame) +{ + switch (flag) { + case 0: + *number_of_coefs = 320; + *sample_rate_bits = 0; + *rate_control_bits = 4; + *rate_control_possibilities = 16; + *checksum_bits = 0; + *esf_adjustment = 7; + *number_of_regions = 14; + *sample_rate_code = 0; + *scale_factor = 22; + break; + case 1: + *number_of_coefs = 320; + *sample_rate_bits = 2; + *rate_control_bits = 4; + *rate_control_possibilities = 16; + *checksum_bits = 4; + *esf_adjustment = -2; + *number_of_regions = 14; + *scale_factor = 1; + if (sample_rate == 16000) + *sample_rate_code = 1; + else if (sample_rate == 24000) + *sample_rate_code = 2; + else if (sample_rate == 32000) + *sample_rate_code = 3; + else + return 3; + break; + case 2: + *number_of_coefs = 640; + *sample_rate_bits = 2; + *rate_control_bits = 5; + *rate_control_possibilities = 32; + *checksum_bits = 4; + *esf_adjustment = 7; + *number_of_regions = 28; + *scale_factor = 33; + + if (sample_rate == 24000) + *sample_rate_code = 1; + else if (sample_rate == 32000) + *sample_rate_code = 2; + else if (sample_rate == 48000) + *sample_rate_code = 3; + else + return 3; + + break; + case 3: + *number_of_coefs = 640; + *sample_rate_bits = 6; + *rate_control_bits = 5; + *rate_control_possibilities = 32; + *checksum_bits = 4; + *esf_adjustment = 7; + *scale_factor = 33; + + switch (sample_rate) { + case 8800: + *number_of_regions = 12; + *sample_rate_code = 59; + break; + case 9600: + *number_of_regions = 12; + *sample_rate_code = 1; + break; + case 10400: + *number_of_regions = 12; + *sample_rate_code = 13; + break; + case 10800: + *number_of_regions = 12; + *sample_rate_code = 14; + break; + case 11200: + *number_of_regions = 12; + *sample_rate_code = 15; + break; + case 11600: + *number_of_regions = 12; + *sample_rate_code = 16; + break; + case 12000: + *number_of_regions = 12; + *sample_rate_code = 2; + break; + case 12400: + *number_of_regions = 12; + *sample_rate_code = 17; + break; + case 12800: + *number_of_regions = 12; + *sample_rate_code = 18; + break; + case 13200: + *number_of_regions = 12; + *sample_rate_code = 19; + break; + case 13600: + *number_of_regions = 12; + *sample_rate_code = 20; + break; + case 14000: + *number_of_regions = 12; + *sample_rate_code = 21; + break; + case 14400: + *number_of_regions = 16; + *sample_rate_code = 3; + break; + case 14800: + *number_of_regions = 16; + *sample_rate_code = 22; + break; + case 15200: + *number_of_regions = 16; + *sample_rate_code = 23; + break; + case 15600: + *number_of_regions = 16; + *sample_rate_code = 24; + break; + case 16000: + *number_of_regions = 16; + *sample_rate_code = 25; + break; + case 16400: + *number_of_regions = 16; + *sample_rate_code = 26; + break; + case 16800: + *number_of_regions = 18; + *sample_rate_code = 4; + break; + case 17200: + *number_of_regions = 18; + *sample_rate_code = 27; + break; + case 17600: + *number_of_regions = 18; + *sample_rate_code = 28; + break; + case 18000: + *number_of_regions = 18; + *sample_rate_code = 29; + break; + case 18400: + *number_of_regions = 18; + *sample_rate_code = 30; + break; + case 18800: + *number_of_regions = 18; + *sample_rate_code = 31; + break; + case 19200: + *number_of_regions = 20; + *sample_rate_code = 5; + break; + case 19600: + *number_of_regions = 20; + *sample_rate_code = 32; + break; + case 20000: + *number_of_regions = 20; + *sample_rate_code = 33; + break; + case 20400: + *number_of_regions = 20; + *sample_rate_code = 34; + break; + case 20800: + *number_of_regions = 20; + *sample_rate_code = 35; + break; + case 21200: + *number_of_regions = 20; + *sample_rate_code = 36; + break; + case 21600: + *number_of_regions = 22; + *sample_rate_code = 6; + break; + case 22000: + *number_of_regions = 22; + *sample_rate_code = 37; + break; + case 22400: + *number_of_regions = 22; + *sample_rate_code = 38; + break; + case 22800: + *number_of_regions = 22; + *sample_rate_code = 39; + break; + case 23200: + *number_of_regions = 22; + *sample_rate_code = 40; + break; + case 23600: + *number_of_regions = 22; + *sample_rate_code = 41; + break; + case 24000: + *number_of_regions = 24; + *sample_rate_code = 7; + break; + case 24400: + *number_of_regions = 24; + *sample_rate_code = 42; + break; + case 24800: + *number_of_regions = 24; + *sample_rate_code = 43; + break; + case 25200: + *number_of_regions = 24; + *sample_rate_code = 44; + break; + case 25600: + *number_of_regions = 24; + *sample_rate_code = 45; + break; + case 26000: + *number_of_regions = 24; + *sample_rate_code = 46; + break; + case 26400: + *number_of_regions = 26; + *sample_rate_code = 8; + break; + case 26800: + *number_of_regions = 26; + *sample_rate_code = 47; + break; + case 27200: + *number_of_regions = 26; + *sample_rate_code = 48; + break; + case 27600: + *number_of_regions = 26; + *sample_rate_code = 49; + break; + case 28000: + *number_of_regions = 26; + *sample_rate_code = 50; + break; + case 28400: + *number_of_regions = 26; + *sample_rate_code = 51; + break; + case 28800: + *number_of_regions = 28; + *sample_rate_code = 9; + break; + case 29200: + *number_of_regions = 28; + *sample_rate_code = 52; + break; + case 29600: + *number_of_regions = 28; + *sample_rate_code = 53; + break; + case 30000: + *number_of_regions = 28; + *sample_rate_code = 54; + break; + case 30400: + *number_of_regions = 28; + *sample_rate_code = 55; + break; + case 30800: + *number_of_regions = 28; + *sample_rate_code = 56; + break; + case 31200: + *number_of_regions = 28; + *sample_rate_code = 10; + break; + case 31600: + *number_of_regions = 28; + *sample_rate_code = 57; + break; + case 32000: + *number_of_regions = 28; + *sample_rate_code = 58; + break; + default: + return 3; + break; + } + break; + default: + return 6; + } + + *bits_per_frame = sample_rate / 50; + return 0; +} diff --git a/Frameworks/g7221/g7221/libsiren/common.h b/Frameworks/g7221/g7221/libsiren/common.h new file mode 100644 index 000000000..a231de8af --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/common.h @@ -0,0 +1,146 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + + +#ifndef _SIREN_COMMON_H +#define _SIREN_COMMON_H + +typedef struct { + unsigned int RiffId; + unsigned int RiffSize; +} RiffHeader; + +typedef struct { + unsigned short Format; + unsigned short Channels; + unsigned int SampleRate; + unsigned int ByteRate; + unsigned short BlockAlign; + unsigned short BitsPerSample; +} FmtChunk; + + +typedef struct { + FmtChunk fmt; + unsigned short ExtraSize; + unsigned short DctLength; +} SirenFmtChunk; + +typedef struct { + RiffHeader riff; + unsigned int WaveId; + + unsigned int FmtId; + unsigned int FmtSize; + + SirenFmtChunk fmt; + + unsigned int FactId; + unsigned int FactSize; + unsigned int Samples; + + unsigned int DataId; + unsigned int DataSize; +} SirenWavHeader; + +typedef struct { + RiffHeader riff; + unsigned int WaveId; + + unsigned int FmtId; + unsigned int FmtSize; + + FmtChunk fmt; + + unsigned int FactId; + unsigned int FactSize; + unsigned int Samples; + + unsigned int DataId; + unsigned int DataSize; +} PCMWavHeader; + +#define RIFF_ID 0x46464952 +#define WAVE_ID 0x45564157 +#define FMT__ID 0x20746d66 +#define DATA_ID 0x61746164 +#define FACT_ID 0x74636166 + + +extern int region_size; +extern float region_size_inverse; +extern float standard_deviation[64]; +extern float deviation_inverse[64]; +extern float region_power_table_boundary[63]; +extern int expected_bits_table[8]; +extern int vector_dimension[8]; +extern int number_of_vectors[8]; +extern float dead_zone[8]; +extern int max_bin[8]; +extern float step_size[8]; +extern float step_size_inverse[8]; + + + +extern void siren_init(void); +extern int categorize_regions(int number_of_regions, int number_of_available_bits, int *absolute_region_power_index, int *power_categories, int *category_balance); +extern int GetSirenCodecInfo(int flag, int sample_rate, int *number_of_coefs, int *sample_rate_bits, int *rate_control_bits, int *rate_control_possibilities, int *checksum_bits, int *esf_adjustment, int *scale_factor, int *number_of_regions, int *sample_rate_code, int *bits_per_frame ); + + +#ifdef __BIG_ENDIAN__ + +#define POW_2_8 256 +#define POW_2_16 65536 +#define POW_2_24 16777216 + +#define IDX(val, i) ((unsigned int) ((unsigned char *) &val)[i]) + + + +#define ME_FROM_LE16(val) ( (unsigned short) ( IDX(val, 0) + IDX(val, 1) * 256 )) +#define ME_FROM_LE32(val) ( (unsigned int) (IDX(val, 0) + IDX(val, 1) * 256 + \ + IDX(val, 2) * 65536 + IDX(val, 3) * 16777216)) + + +#define ME_TO_LE16(val) ( (unsigned short) ( \ + (((unsigned short)val % 256) & 0xff) << 8 | \ + ((((unsigned short)val / POW_2_8) % 256) & 0xff) )) + +#define ME_TO_LE32(val) ( (unsigned int) ( \ + ((((unsigned int) val ) % 256) & 0xff) << 24 | \ + ((((unsigned int) val / POW_2_8 ) % 256) & 0xff) << 16| \ + ((((unsigned int) val / POW_2_16) % 256) & 0xff) << 8 | \ + ((((unsigned int) val / POW_2_24) % 256) & 0xff) )) + +#else + +#define ME_TO_LE16(val) ( (unsigned short) (val)) +#define ME_TO_LE32(val) ( (unsigned int) (val)) +#define ME_FROM_LE16(val) ( (unsigned short) (val)) +#define ME_FROM_LE32(val) ( (unsigned int) (val)) + + +#endif + + + +#endif /* _SIREN_COMMON_H */ + diff --git a/Frameworks/g7221/g7221/libsiren/dct4.c b/Frameworks/g7221/g7221/libsiren/dct4.c new file mode 100644 index 000000000..db2dfbad6 --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/dct4.c @@ -0,0 +1,199 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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 "siren7.h" + + +#define PI 3.1415926 + +typedef struct +{ + float cos; + float msin; +} dct_table_type; + +static float dct_core_320[100]; +static float dct_core_640[100]; +static dct_table_type dct_table_5[5]; +static dct_table_type dct_table_10[10]; +static dct_table_type dct_table_20[20]; +static dct_table_type dct_table_40[40]; +static dct_table_type dct_table_80[80]; +static dct_table_type dct_table_160[160]; +static dct_table_type dct_table_320[320]; +static dct_table_type dct_table_640[640]; +static dct_table_type *dct_tables[8] = { dct_table_5, + dct_table_10, + dct_table_20, + dct_table_40, + dct_table_80, + dct_table_160, + dct_table_320, + dct_table_640 +}; + +static int dct4_initialized = 0; + +void +siren_dct4_init (void) +{ + int i, j = 0; + double scale_320 = (float) sqrt (2.0 / 320); + double scale_640 = (float) sqrt (2.0 / 640); + double angle; + double scale; + + /* set up dct4 tables */ + for (i = 0; i < 10; i++) { + angle = (float) ((i + 0.5) * PI); + for (j = 0; j < 10; j++) { + dct_core_320[(i * 10) + j] = + (float) (scale_320 * cos ((j + 0.5) * angle / 10)); + dct_core_640[(i * 10) + j] = + (float) (scale_640 * cos ((j + 0.5) * angle / 10)); + } + } + + for (i = 0; i < 8; i++) { + scale = (float) (PI / ((5 << i) * 4)); + for (j = 0; j < (5 << i); j++) { + angle = (float) (j + 0.5) * scale; + dct_tables[i][j].cos = (float) cos (angle); + dct_tables[i][j].msin = (float) -sin (angle); + } + } + + dct4_initialized = 1; +} + + +void +siren_dct4 (float *Source, float *Destination, int dct_length) +{ + int log_length = 0; + float *dct_core = NULL; + dct_table_type **dct_table_ptr_ptr = NULL; + dct_table_type *dct_table_ptr = NULL; + float OutBuffer1[640]; + float OutBuffer2[640]; + float *Out_ptr; + float *NextOut_ptr; + float *In_Ptr = NULL; + float *In_Ptr_low = NULL; + float *In_Ptr_high = NULL; + float In_val_low; + float In_val_high; + float *Out_ptr_low = NULL; + float *Out_ptr_high = NULL; + float mult1, mult2, mult3, mult4, mult5, mult6, mult7, mult8, mult9, mult10; + int i, j; + + if (dct4_initialized == 0) + siren_dct4_init (); + + if (dct_length == 640) { + log_length = 5; + dct_core = dct_core_640; + } else { + log_length = 4; + dct_core = dct_core_320; + } + + Out_ptr = OutBuffer1; + NextOut_ptr = OutBuffer2; + In_Ptr = Source; + for (i = 0; i <= log_length; i++) { + for (j = 0; j < (1 << i); j++) { + Out_ptr_low = Out_ptr + (j * (dct_length >> i)); + Out_ptr_high = Out_ptr + ((j + 1) * (dct_length >> i)); + do { + In_val_low = *In_Ptr++; + In_val_high = *In_Ptr++; + *Out_ptr_low++ = In_val_low + In_val_high; + *--Out_ptr_high = In_val_low - In_val_high; + } while (Out_ptr_low < Out_ptr_high); + } + + In_Ptr = Out_ptr; + Out_ptr = NextOut_ptr; + NextOut_ptr = In_Ptr; + } + + for (i = 0; i < (2 << log_length); i++) { + for (j = 0; j < 10; j++) { + mult1 = In_Ptr[(i * 10)] * dct_core[j * 10]; + mult2 = In_Ptr[(i * 10) + 1] * dct_core[(j * 10) + 1]; + mult3 = In_Ptr[(i * 10) + 2] * dct_core[(j * 10) + 2]; + mult4 = In_Ptr[(i * 10) + 3] * dct_core[(j * 10) + 3]; + mult5 = In_Ptr[(i * 10) + 4] * dct_core[(j * 10) + 4]; + mult6 = In_Ptr[(i * 10) + 5] * dct_core[(j * 10) + 5]; + mult7 = In_Ptr[(i * 10) + 6] * dct_core[(j * 10) + 6]; + mult8 = In_Ptr[(i * 10) + 7] * dct_core[(j * 10) + 7]; + mult9 = In_Ptr[(i * 10) + 8] * dct_core[(j * 10) + 8]; + mult10 = In_Ptr[(i * 10) + 9] * dct_core[(j * 10) + 9]; + Out_ptr[(i * 10) + j] = mult1 + mult2 + mult3 + mult4 + + mult5 + mult6 + mult7 + mult8 + mult9 + mult10; + } + } + + + In_Ptr = Out_ptr; + Out_ptr = NextOut_ptr; + NextOut_ptr = In_Ptr; + dct_table_ptr_ptr = dct_tables; + for (i = log_length; i >= 0; i--) { + dct_table_ptr_ptr++; + for (j = 0; j < (1 << i); j++) { + dct_table_ptr = *dct_table_ptr_ptr; + if (i == 0) + Out_ptr_low = Destination + (j * (dct_length >> i)); + else + Out_ptr_low = Out_ptr + (j * (dct_length >> i)); + + Out_ptr_high = Out_ptr_low + (dct_length >> i); + + In_Ptr_low = In_Ptr + (j * (dct_length >> i)); + In_Ptr_high = In_Ptr_low + (dct_length >> (i + 1)); + do { + *Out_ptr_low++ = + (*In_Ptr_low * (*dct_table_ptr).cos) - + (*In_Ptr_high * (*dct_table_ptr).msin); + *--Out_ptr_high = + (*In_Ptr_high++ * (*dct_table_ptr).cos) + + (*In_Ptr_low++ * (*dct_table_ptr).msin); + dct_table_ptr++; + *Out_ptr_low++ = + (*In_Ptr_low * (*dct_table_ptr).cos) + + (*In_Ptr_high * (*dct_table_ptr).msin); + *--Out_ptr_high = + (*In_Ptr_low++ * (*dct_table_ptr).msin) - + (*In_Ptr_high++ * (*dct_table_ptr).cos); + dct_table_ptr++; + } while (Out_ptr_low < Out_ptr_high); + } + + In_Ptr = Out_ptr; + Out_ptr = NextOut_ptr; + NextOut_ptr = In_Ptr; + } + +} diff --git a/Frameworks/g7221/g7221/libsiren/dct4.h b/Frameworks/g7221/g7221/libsiren/dct4.h new file mode 100644 index 000000000..5bdd0e07a --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/dct4.h @@ -0,0 +1,30 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + + +#ifndef _SIREN7_DCT4_H_ +#define _SIREN7_DCT4_H_ + +extern void siren_dct4_init(void); +extern void siren_dct4(float *Source, float *Destination, int dct_length); + + +#endif /* _SIREN7_DCT4_H_ */ diff --git a/Frameworks/g7221/g7221/libsiren/decoder.c b/Frameworks/g7221/g7221/libsiren/decoder.c new file mode 100644 index 000000000..af1864f9a --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/decoder.c @@ -0,0 +1,273 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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 "siren7.h" + +SirenDecoder +Siren7_NewDecoder (int sample_rate, int flag) +{ + SirenDecoder decoder = (SirenDecoder) malloc (sizeof (struct stSirenDecoder)); + decoder->sample_rate = sample_rate; + decoder->flag = flag; + +#ifdef __WAV_HEADER__ + decoder->WavHeader.riff.RiffId = ME_TO_LE32 (RIFF_ID); + decoder->WavHeader.riff.RiffSize = sizeof (PCMWavHeader) - 2 * sizeof (int); + decoder->WavHeader.riff.RiffSize = + ME_TO_LE32 (decoder->WavHeader.riff.RiffSize); + decoder->WavHeader.WaveId = ME_TO_LE32 (WAVE_ID); + + decoder->WavHeader.FmtId = ME_TO_LE32 (FMT__ID); + decoder->WavHeader.FmtSize = ME_TO_LE32 (sizeof (FmtChunk)); + + decoder->WavHeader.fmt.Format = ME_TO_LE16 (0x01); + decoder->WavHeader.fmt.Channels = ME_TO_LE16 (1); + decoder->WavHeader.fmt.SampleRate = ME_TO_LE32 (sample_rate); + decoder->WavHeader.fmt.ByteRate = ME_TO_LE32 (sample_rate * 2); + decoder->WavHeader.fmt.BlockAlign = ME_TO_LE16 (2); + decoder->WavHeader.fmt.BitsPerSample = ME_TO_LE16 (16); + + decoder->WavHeader.FactId = ME_TO_LE32 (FACT_ID); + decoder->WavHeader.FactSize = ME_TO_LE32 (sizeof (int)); + decoder->WavHeader.Samples = ME_TO_LE32 (0); + + decoder->WavHeader.DataId = ME_TO_LE32 (DATA_ID); + decoder->WavHeader.DataSize = ME_TO_LE32 (0); +#endif + + Siren7_ResetDecoder(decoder); + + siren_init (); + return decoder; +} + +void +Siren7_ResetDecoder(SirenDecoder decoder) +{ + memset(decoder->context, 0, sizeof(decoder->context)); + memset(decoder->backup_frame, 0, sizeof(decoder->backup_frame)); + + decoder->dw1 = 1; + decoder->dw2 = 1; + decoder->dw3 = 1; + decoder->dw4 = 1; + + memset(decoder->absolute_region_power_index, 0, sizeof(decoder->absolute_region_power_index)); + memset(decoder->decoder_standard_deviation, 0, sizeof(decoder->decoder_standard_deviation)); + memset(decoder->power_categories, 0, sizeof(decoder->power_categories)); + memset(decoder->category_balance, 0, sizeof(decoder->category_balance)); +} + +void +Siren7_CloseDecoder (SirenDecoder decoder) +{ + free (decoder); +} + +int +Siren7_DecodeFrame (SirenDecoder decoder, unsigned char *DataIn, + unsigned char *DataOut) +{ + int number_of_coefs, + sample_rate_bits, + rate_control_bits, + rate_control_possibilities, + checksum_bits, + esf_adjustment, + scale_factor, number_of_regions, sample_rate_code, bits_per_frame; + int decoded_sample_rate_code; + + int ChecksumTable[4] = { 0x7F80, 0x7878, 0x6666, 0x5555 }; + int i, j; + + int dwRes = 0; + int envelope_bits = 0; + int rate_control = 0; + int number_of_available_bits; + int number_of_valid_coefs; + int frame_error = 0; + + int In[60]; + float coefs[640]; + float BufferOut[640]; + int sum; + int checksum; + int calculated_checksum; + int idx; + int temp1; + int temp2; + + bitstream bs = {0}; + + dwRes = + GetSirenCodecInfo (decoder->flag, decoder->sample_rate, &number_of_coefs, + &sample_rate_bits, &rate_control_bits, &rate_control_possibilities, + &checksum_bits, &esf_adjustment, &scale_factor, &number_of_regions, + &sample_rate_code, &bits_per_frame); + + if (dwRes != 0) + return dwRes; + +#ifdef __NO_CONTROL_OR_CHECK_FIELDS__ + sample_rate_bits = 0; + checksum_bits = 0; + sample_rate_code = 0; +#endif + + j = bits_per_frame / 16; + + for (i = 0; i < j; i++) +#ifdef __BIG_ENDIAN_FRAMES__ + In[i] = ((short *) DataIn)[i]; +#else + In[i] = + ((((short *) DataIn)[i] << 8) & 0xFF00) | ((((short *) DataIn)[i] >> 8) + & 0x00FF); +#endif + + set_bitstream (&bs, In); + + decoded_sample_rate_code = 0; + for (i = 0; i < sample_rate_bits; i++) { + decoded_sample_rate_code <<= 1; + decoded_sample_rate_code |= next_bit (&bs); + } + + + if (decoded_sample_rate_code != sample_rate_code) + return 7; + + number_of_valid_coefs = region_size * number_of_regions; + number_of_available_bits = bits_per_frame - sample_rate_bits - checksum_bits; + + + envelope_bits = + decode_envelope (&bs, number_of_regions, decoder->decoder_standard_deviation, + decoder->absolute_region_power_index, esf_adjustment); + + number_of_available_bits -= envelope_bits; + + for (i = 0; i < rate_control_bits; i++) { + rate_control <<= 1; + rate_control |= next_bit (&bs); + } + + number_of_available_bits -= rate_control_bits; + + categorize_regions (number_of_regions, number_of_available_bits, + decoder->absolute_region_power_index, decoder->power_categories, decoder->category_balance); + + for (i = 0; i < rate_control; i++) { + decoder->power_categories[decoder->category_balance[i]]++; + } + + number_of_available_bits = + decode_vector (decoder, &bs, number_of_regions, number_of_available_bits, + decoder->decoder_standard_deviation, decoder->power_categories, coefs, scale_factor); + + + frame_error = 0; + if (number_of_available_bits > 0) { + for (i = 0; i < number_of_available_bits; i++) { + if (next_bit (&bs) == 0) + frame_error = 1; + } + } else if (number_of_available_bits < 0 + && rate_control + 1 < rate_control_possibilities) { + frame_error |= 2; + } + + for (i = 0; i < number_of_regions; i++) { + if (decoder->absolute_region_power_index[i] > 33 + || decoder->absolute_region_power_index[i] < -31) + frame_error |= 4; + } + + if (checksum_bits > 0) { + bits_per_frame >>= 4; + checksum = In[bits_per_frame - 1] & ((1 << checksum_bits) - 1); + In[bits_per_frame - 1] &= ~checksum; + sum = 0; + idx = 0; + do { + sum ^= (In[idx] & 0xFFFF) << (idx % 15); + } while (++idx < bits_per_frame); + + sum = (sum >> 15) ^ (sum & 0x7FFF); + calculated_checksum = 0; + for (i = 0; i < 4; i++) { + temp1 = ChecksumTable[i] & sum; + for (j = 8; j > 0; j >>= 1) { + temp2 = temp1 >> j; + temp1 ^= temp2; + } + calculated_checksum <<= 1; + calculated_checksum |= temp1 & 1; + } + + if (checksum != calculated_checksum) + frame_error |= 8; + } + + if (frame_error != 0) { + for (i = 0; i < number_of_valid_coefs; i++) { + coefs[i] = decoder->backup_frame[i]; + decoder->backup_frame[i] = 0; + } + } else { + for (i = 0; i < number_of_valid_coefs; i++) + decoder->backup_frame[i] = coefs[i]; + } + + + for (i = number_of_valid_coefs; i < number_of_coefs; i++) + coefs[i] = 0; + + + dwRes = siren_rmlt_decode_samples (coefs, decoder->context, number_of_coefs, BufferOut); + + + for (i = 0; i < number_of_coefs; i++) { + if (BufferOut[i] > 32767.0) + ((short *) DataOut)[i] = (short) ME_TO_LE16 ((short) 32767); + else if (BufferOut[i] <= -32768.0) + ((short *) DataOut)[i] = (short) ME_TO_LE16 ((short) 32768); + else + ((short *) DataOut)[i] = (short) ME_TO_LE16 ((short) BufferOut[i]); + } + +#ifdef __WAV_HEADER__ + decoder->WavHeader.Samples = ME_FROM_LE32 (decoder->WavHeader.Samples); + decoder->WavHeader.Samples += number_of_coefs; + decoder->WavHeader.Samples = ME_TO_LE32 (decoder->WavHeader.Samples); + decoder->WavHeader.DataSize = ME_FROM_LE32 (decoder->WavHeader.DataSize); + decoder->WavHeader.DataSize += number_of_coefs * 2; + decoder->WavHeader.DataSize = ME_TO_LE32 (decoder->WavHeader.DataSize); + decoder->WavHeader.riff.RiffSize = + ME_FROM_LE32 (decoder->WavHeader.riff.RiffSize); + decoder->WavHeader.riff.RiffSize += number_of_coefs * 2; + decoder->WavHeader.riff.RiffSize = + ME_TO_LE32 (decoder->WavHeader.riff.RiffSize); +#endif + + return 0; +} diff --git a/Frameworks/g7221/g7221/libsiren/decoder.h b/Frameworks/g7221/g7221/libsiren/decoder.h new file mode 100644 index 000000000..641c06dd7 --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/decoder.h @@ -0,0 +1,63 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + + +#ifndef _SIREN_DECODER_H +#define _SIREN_DECODER_H + +#include +#include +#include +#include "dct4.h" +#include "rmlt.h" +#include "huffman.h" +#include "common.h" + + +typedef struct stSirenDecoder { + int sample_rate; + int flag; +#ifdef __WAV_HEADER__ + PCMWavHeader WavHeader; +#endif + float context[640]; + float backup_frame[640]; + int dw1; + int dw2; + int dw3; + int dw4; + int absolute_region_power_index[28]; + float decoder_standard_deviation[28]; + int power_categories[28]; + int category_balance[32]; +} * SirenDecoder; + + +/* MUST be 16000 to be compatible with MSN Voice clips (I think) */ +extern SirenDecoder Siren7_NewDecoder(int sample_rate, int flag); /* flag = 1 for Siren7 and 2 for Siren14 */ +extern void Siren7_CloseDecoder(SirenDecoder decoder); +extern void Siren7_ResetDecoder(SirenDecoder decoder); +/* Input bytes / output samples */ +/* Siren7: 60 / 320 */ +/* Siren14: 120 / 640 */ +extern int Siren7_DecodeFrame(SirenDecoder decoder, unsigned char *DataIn, unsigned char *DataOut); + +#endif /* _SIREN_DECODER_H */ diff --git a/Frameworks/g7221/g7221/libsiren/encoder.c b/Frameworks/g7221/g7221/libsiren/encoder.c new file mode 100644 index 000000000..aece6d44d --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/encoder.c @@ -0,0 +1,267 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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 "siren7.h" + + +SirenEncoder +Siren7_NewEncoder (int sample_rate, int flag) +{ + SirenEncoder encoder = (SirenEncoder) malloc (sizeof (struct stSirenEncoder)); + encoder->sample_rate = sample_rate; + encoder->flag = flag; + +#ifdef __WAV_HEADER__ + encoder->WavHeader.riff.RiffId = ME_TO_LE32 (RIFF_ID); + encoder->WavHeader.riff.RiffSize = sizeof (SirenWavHeader) - 2 * sizeof (int); + encoder->WavHeader.riff.RiffSize = + ME_TO_LE32 (encoder->WavHeader.riff.RiffSize); + encoder->WavHeader.WaveId = ME_TO_LE32 (WAVE_ID); + + encoder->WavHeader.FmtId = ME_TO_LE32 (FMT__ID); + encoder->WavHeader.FmtSize = ME_TO_LE32 (sizeof (SirenFmtChunk)); + + encoder->WavHeader.fmt.fmt.Format = ME_TO_LE16 (0x028E); + encoder->WavHeader.fmt.fmt.Channels = ME_TO_LE16 (1); + encoder->WavHeader.fmt.fmt.SampleRate = ME_TO_LE32 (sample_rate); + encoder->WavHeader.fmt.fmt.ByteRate = ME_TO_LE32 (sample_rate * 16 / 3); + encoder->WavHeader.fmt.fmt.BlockAlign = ME_TO_LE16 (40); + encoder->WavHeader.fmt.fmt.BitsPerSample = ME_TO_LE16 (0); + encoder->WavHeader.fmt.ExtraSize = ME_TO_LE16 (2); + encoder->WavHeader.fmt.DctLength = ME_TO_LE16 (flag == 1 ? 320 : 640); + + encoder->WavHeader.FactId = ME_TO_LE32 (FACT_ID); + encoder->WavHeader.FactSize = ME_TO_LE32 (sizeof (int)); + encoder->WavHeader.Samples = ME_TO_LE32 (0); + + encoder->WavHeader.DataId = ME_TO_LE32 (DATA_ID); + encoder->WavHeader.DataSize = ME_TO_LE32 (0); +#endif + + memset (encoder->context, 0, sizeof (encoder->context)); + + memset (encoder->absolute_region_power_index, 0, sizeof(encoder->absolute_region_power_index)); + memset (encoder->power_categories, 0, sizeof(encoder->power_categories)); + memset (encoder->category_balance, 0, sizeof(encoder->category_balance)); + memset (encoder->drp_num_bits, 0, sizeof(encoder->drp_num_bits)); + memset (encoder->drp_code_bits, 0, sizeof(encoder->drp_code_bits)); + memset (encoder->region_mlt_bit_counts, 0, sizeof(encoder->region_mlt_bit_counts)); + memset (encoder->region_mlt_bits, 0, sizeof(encoder->region_mlt_bits)); + + siren_init (); + return encoder; +} + +void +Siren7_CloseEncoder (SirenEncoder encoder) +{ + free (encoder); +} + + + +int +Siren7_EncodeFrame (SirenEncoder encoder, unsigned char *DataIn, + unsigned char *DataOut) +{ + int number_of_coefs, + sample_rate_bits, + rate_control_bits, + rate_control_possibilities, + checksum_bits, + esf_adjustment, + scale_factor, number_of_regions, sample_rate_code, bits_per_frame; + int sample_rate = encoder->sample_rate; + + int ChecksumTable[4] = { 0x7F80, 0x7878, 0x6666, 0x5555 }; + int i, j; + + int dwRes = 0; + short out_word; + int bits_left; + int current_word_bits_left; + int region_bit_count; + unsigned int current_word; + unsigned int sum; + unsigned int checksum; + int temp1 = 0; + int temp2 = 0; + int region; + int idx = 0; + int envelope_bits = 0; + int rate_control; + int number_of_available_bits; + + float coefs[640]; + float In[640]; + short BufferOut[60]; + float *context = encoder->context; + + dwRes = + GetSirenCodecInfo (encoder->flag, sample_rate, &number_of_coefs, &sample_rate_bits, + &rate_control_bits, &rate_control_possibilities, &checksum_bits, + &esf_adjustment, &scale_factor, &number_of_regions, &sample_rate_code, + &bits_per_frame); + + if (dwRes != 0) + return dwRes; + +#ifdef __NO_CONTROL_OR_CHECK_FIELDS__ + sample_rate_bits = 0; + checksum_bits = 0; + sample_rate_code = 0; +#endif + + for (i = 0; i < number_of_coefs; i++) + In[i] = (float) ((short) ME_FROM_LE16 (((short *) DataIn)[i])); + + dwRes = siren_rmlt_encode_samples (In, context, number_of_coefs, coefs); + + if (dwRes != 0) + return dwRes; + + envelope_bits = + compute_region_powers (number_of_regions, coefs, encoder->drp_num_bits, + encoder->drp_code_bits, encoder->absolute_region_power_index, esf_adjustment); + + number_of_available_bits = + bits_per_frame - rate_control_bits - envelope_bits - sample_rate_bits - + checksum_bits; + + categorize_regions (number_of_regions, number_of_available_bits, + encoder->absolute_region_power_index, encoder->power_categories, encoder->category_balance); + + for (region = 0; region < number_of_regions; region++) { + encoder->absolute_region_power_index[region] += 24; + encoder->region_mlt_bit_counts[region] = 0; + } + + rate_control = + quantize_mlt (number_of_regions, rate_control_possibilities, + number_of_available_bits, coefs, encoder->absolute_region_power_index, + encoder->power_categories, encoder->category_balance, encoder->region_mlt_bit_counts, + encoder->region_mlt_bits); + + idx = 0; + bits_left = 16 - sample_rate_bits; + out_word = sample_rate_code << (16 - sample_rate_bits); + encoder->drp_num_bits[number_of_regions] = rate_control_bits; + encoder->drp_code_bits[number_of_regions] = rate_control; + for (region = 0; region <= number_of_regions; region++) { + i = encoder->drp_num_bits[region] - bits_left; + if (i < 0) { + out_word += encoder->drp_code_bits[region] << -i; + bits_left -= encoder->drp_num_bits[region]; + } else { + BufferOut[idx++] = out_word + (encoder->drp_code_bits[region] >> i); + bits_left += 16 - encoder->drp_num_bits[region]; + out_word = encoder->drp_code_bits[region] << bits_left; + } + } + + for (region = 0; region < number_of_regions && (16 * idx) < bits_per_frame; + region++) { + current_word_bits_left = region_bit_count = encoder->region_mlt_bit_counts[region]; + if (current_word_bits_left > 32) + current_word_bits_left = 32; + + current_word = encoder->region_mlt_bits[region * 4]; + i = 1; + while (region_bit_count > 0 && (16 * idx) < bits_per_frame) { + if (current_word_bits_left < bits_left) { + bits_left -= current_word_bits_left; + out_word += + (current_word >> (32 - current_word_bits_left)) << bits_left; + current_word_bits_left = 0; + } else { + BufferOut[idx++] = + (short) (out_word + (current_word >> (32 - bits_left))); + current_word_bits_left -= bits_left; + current_word <<= bits_left; + bits_left = 16; + out_word = 0; + } + if (current_word_bits_left == 0) { + region_bit_count -= 32; + current_word = encoder->region_mlt_bits[(region * 4) + i++]; + current_word_bits_left = region_bit_count; + if (current_word_bits_left > 32) + current_word_bits_left = 32; + } + } + } + + + while ((16 * idx) < bits_per_frame) { + BufferOut[idx++] = (short) ((0xFFFF >> (16 - bits_left)) + out_word); + bits_left = 16; + out_word = 0; + } + + if (checksum_bits > 0) { + BufferOut[idx - 1] &= (-1 << checksum_bits); + sum = 0; + idx = 0; + do { + sum ^= (BufferOut[idx] & 0xFFFF) << (idx % 15); + } while ((16 * ++idx) < bits_per_frame); + + sum = (sum >> 15) ^ (sum & 0x7FFF); + checksum = 0; + for (i = 0; i < 4; i++) { + temp1 = ChecksumTable[i] & sum; + for (j = 8; j > 0; j >>= 1) { + temp2 = temp1 >> j; + temp1 ^= temp2; + } + checksum <<= 1; + checksum |= temp1 & 1; + } + BufferOut[idx - 1] |= ((1 << checksum_bits) - 1) & checksum; + } + + j = bits_per_frame / 16; + for (i = 0; i < j; i++) +#ifdef __BIG_ENDIAN_FRAMES__ + ((short *) DataOut)[i] = BufferOut[i]; +#else + ((short *) DataOut)[i] = + ((BufferOut[i] << 8) & 0xFF00) | ((BufferOut[i] >> 8) & 0x00FF); +#endif + +#ifdef __WAV_HEADER__ + encoder->WavHeader.Samples = ME_FROM_LE32 (encoder->WavHeader.Samples); + encoder->WavHeader.Samples += number_of_coefs; + encoder->WavHeader.Samples = ME_TO_LE32 (encoder->WavHeader.Samples); + encoder->WavHeader.DataSize = ME_FROM_LE32 (encoder->WavHeader.DataSize); + encoder->WavHeader.DataSize += bits_per_Frame / 8; + encoder->WavHeader.DataSize = ME_TO_LE32 (encoder->WavHeader.DataSize); + encoder->WavHeader.riff.RiffSize = + ME_FROM_LE32 (encoder->WavHeader.riff.RiffSize); + encoder->WavHeader.riff.RiffSize += bits_per_Frame / 8; + encoder->WavHeader.riff.RiffSize = + ME_TO_LE32 (encoder->WavHeader.riff.RiffSize); +#endif + + return 0; +} diff --git a/Frameworks/g7221/g7221/libsiren/encoder.h b/Frameworks/g7221/g7221/libsiren/encoder.h new file mode 100644 index 000000000..07af2fa33 --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/encoder.h @@ -0,0 +1,60 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + + +#ifndef _SIREN_ENCODER_H +#define _SIREN_ENCODER_H + +#include +#include +#include +#include "dct4.h" +#include "rmlt.h" +#include "huffman.h" +#include "common.h" + + +typedef struct stSirenEncoder { + int sample_rate; + int flag; +#ifdef __WAV_HEADER__ + SirenWavHeader WavHeader; +#endif + float context[640]; + int absolute_region_power_index[28]; + int power_categories[28]; + int category_balance[32]; + int drp_num_bits[30]; + int drp_code_bits[30]; + int region_mlt_bit_counts[28]; + int region_mlt_bits[112]; +} * SirenEncoder; + +/* sample_rate MUST be 16000 to be compatible with MSN Voice clips (I think) */ +extern SirenEncoder Siren7_NewEncoder(int sample_rate, int flag); /* flag = 1 for Siren7 and 2 for Siren14 */ +extern void Siren7_CloseEncoder(SirenEncoder encoder); +/* Input samples / output bytes */ +/* Siren7: 320 / 60 */ +/* Siren14: 640 / 120 */ +extern int Siren7_EncodeFrame(SirenEncoder encoder, unsigned char *DataIn, unsigned char *DataOut); + + +#endif /* _SIREN_ENCODER_H */ diff --git a/Frameworks/g7221/g7221/libsiren/huffman.c b/Frameworks/g7221/g7221/libsiren/huffman.c new file mode 100644 index 000000000..762b19e43 --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/huffman.c @@ -0,0 +1,425 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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 "siren7.h" +#include "huffman_consts.h" +#include "huffman.h" + +int +next_bit (bitstream *bs) +{ + if (bs == NULL || bs->bitstream_ptr == NULL) + return -1; + + if (bs->bit_idx == 0) { + bs->current_word = *bs->bitstream_ptr++; + bs->bit_idx = 16; + } + + return (bs->current_word >> --bs->bit_idx) & 1; +} + +void +set_bitstream (bitstream *bs, int *stream) +{ + bs->bitstream_ptr = stream; + bs->current_word = *bs->bitstream_ptr; + bs->bit_idx = 0; +} + + +int +compute_region_powers (int number_of_regions, float *coefs, int *drp_num_bits, + int *drp_code_bits, int *absolute_region_power_index, int esf_adjustment) +{ + float region_power = 0; + int num_bits; + int idx; + int max_idx, min_idx; + int region, i; + + for (region = 0; region < number_of_regions; region++) { + region_power = 0.0f; + for (i = 0; i < region_size; i++) { + region_power += + coefs[(region * region_size) + i] * coefs[(region * region_size) + i]; + } + region_power *= region_size_inverse; + + min_idx = 0; + max_idx = 64; + for (i = 0; i < 6; i++) { + idx = (min_idx + max_idx) / 2; + if (region_power_table_boundary[idx - 1] <= region_power) { + min_idx = idx; + } else { + max_idx = idx; + } + } + absolute_region_power_index[region] = min_idx - 24; + + } + + for (region = number_of_regions - 2; region >= 0; region--) { + if (absolute_region_power_index[region] < + absolute_region_power_index[region + 1] - 11) + absolute_region_power_index[region] = + absolute_region_power_index[region + 1] - 11; + } + + if (absolute_region_power_index[0] < (1 - esf_adjustment)) + absolute_region_power_index[0] = (1 - esf_adjustment); + + if (absolute_region_power_index[0] > (31 - esf_adjustment)) + absolute_region_power_index[0] = (31 - esf_adjustment); + + drp_num_bits[0] = 5; + drp_code_bits[0] = absolute_region_power_index[0] + esf_adjustment; + + + for (region = 1; region < number_of_regions; region++) { + if (absolute_region_power_index[region] < (-8 - esf_adjustment)) + absolute_region_power_index[region] = (-8 - esf_adjustment); + if (absolute_region_power_index[region] > (31 - esf_adjustment)) + absolute_region_power_index[region] = (31 - esf_adjustment); + } + + num_bits = 5; + + for (region = 0; region < number_of_regions - 1; region++) { + idx = + absolute_region_power_index[region + 1] - + absolute_region_power_index[region] + 12; + if (idx < 0) + idx = 0; + + absolute_region_power_index[region + 1] = + absolute_region_power_index[region] + idx - 12; + drp_num_bits[region + 1] = differential_region_power_bits[region][idx]; + drp_code_bits[region + 1] = differential_region_power_codes[region][idx]; + num_bits += drp_num_bits[region + 1]; + } + + return num_bits; +} + + +int +decode_envelope (bitstream *bs, int number_of_regions, float *decoder_standard_deviation, + int *absolute_region_power_index, int esf_adjustment) +{ + int index; + int i; + int envelope_bits = 0; + + index = 0; + for (i = 0; i < 5; i++) + index = (index << 1) | next_bit (bs); + envelope_bits = 5; + + absolute_region_power_index[0] = index - esf_adjustment; + decoder_standard_deviation[0] = + standard_deviation[absolute_region_power_index[0] + 24]; + + for (i = 1; i < number_of_regions; i++) { + index = 0; + do { + index = differential_decoder_tree[i - 1][index][next_bit (bs)]; + envelope_bits++; + } while (index > 0); + + absolute_region_power_index[i] = + absolute_region_power_index[i - 1] - index - 12; + decoder_standard_deviation[i] = + standard_deviation[absolute_region_power_index[i] + 24]; + } + + return envelope_bits; +} + + + +static int +huffman_vector (int category, int power_idx, float *mlts, int *out) +{ + int i, j; + float temp_value = deviation_inverse[power_idx] * step_size_inverse[category]; + int sign_idx, idx, non_zeroes, max, bits_available; + int current_word = 0; + int region_bits = 0; + + bits_available = 32; + for (i = 0; i < number_of_vectors[category]; i++) { + sign_idx = idx = non_zeroes = 0; + for (j = 0; j < vector_dimension[category]; j++) { + max = (int) ((fabs (*mlts) * temp_value) + dead_zone[category]); + if (max != 0) { + sign_idx <<= 1; + non_zeroes++; + if (*mlts > 0) + sign_idx++; + if (max > max_bin[category] || max < 0) + max = max_bin[category]; + + } + mlts++; + idx = (idx * (max_bin[category] + 1)) + max; + } + + region_bits += bitcount_tables[category][idx] + non_zeroes; + bits_available -= bitcount_tables[category][idx] + non_zeroes; + if (bits_available < 0) { + *out++ = + current_word + (((code_tables[category][idx] << non_zeroes) + + sign_idx) >> -bits_available); + bits_available += 32; + current_word = + ((code_tables[category][idx] << non_zeroes) + + sign_idx) << bits_available; + } else { + current_word += + ((code_tables[category][idx] << non_zeroes) + + sign_idx) << bits_available; + } + + } + + *out = current_word; + return region_bits; +} + +int +quantize_mlt (int number_of_regions, int rate_control_possibilities, + int number_of_available_bits, float *coefs, + int *absolute_region_power_index, int *power_categories, + int *category_balance, int *region_mlt_bit_counts, int *region_mlt_bits) +{ + int region; + int mlt_bits = 0; + int rate_control; + + for (rate_control = 0; rate_control < ((rate_control_possibilities >> 1) - 1); + rate_control++) + power_categories[category_balance[rate_control]]++; + + for (region = 0; region < number_of_regions; region++) { + if (power_categories[region] > 6) + region_mlt_bit_counts[region] = 0; + else + region_mlt_bit_counts[region] = + huffman_vector (power_categories[region], + absolute_region_power_index[region], coefs + (region_size * region), + region_mlt_bits + (4 * region)); + mlt_bits += region_mlt_bit_counts[region]; + } + + while (mlt_bits < number_of_available_bits && rate_control > 0) { + rate_control--; + region = category_balance[rate_control]; + power_categories[region]--; + + if (power_categories[region] < 0) + power_categories[region] = 0; + + mlt_bits -= region_mlt_bit_counts[region]; + + if (power_categories[region] > 6) + region_mlt_bit_counts[region] = 0; + else + region_mlt_bit_counts[region] = + huffman_vector (power_categories[region], + absolute_region_power_index[region], coefs + (region_size * region), + region_mlt_bits + (4 * region)); + + mlt_bits += region_mlt_bit_counts[region]; + } + + while (mlt_bits > number_of_available_bits + && rate_control < rate_control_possibilities) { + region = category_balance[rate_control]; + power_categories[region]++; + mlt_bits -= region_mlt_bit_counts[region]; + + if (power_categories[region] > 6) + region_mlt_bit_counts[region] = 0; + else + region_mlt_bit_counts[region] = + huffman_vector (power_categories[region], + absolute_region_power_index[region], coefs + (region_size * region), + region_mlt_bits + (4 * region)); + + mlt_bits += region_mlt_bit_counts[region]; + + rate_control++; + } + + return rate_control; +} + +static int +get_dw (SirenDecoder decoder) +{ + int ret = decoder->dw1 + decoder->dw4; + + if ((ret & 0x8000) != 0) + ret++; + + decoder->dw1 = decoder->dw2; + decoder->dw2 = decoder->dw3; + decoder->dw3 = decoder->dw4; + decoder->dw4 = ret; + + return ret; +} + + + + +int +decode_vector (SirenDecoder decoder, bitstream *bs, int number_of_regions, + int number_of_available_bits, float *decoder_standard_deviation, + int *power_categories, float *coefs, int scale_factor) +{ + float *coefs_ptr; + float decoded_value; + float noise; + const int *decoder_tree; + + int region; + int category; + int i, j; + int index; + int error; + int dw1; + int dw2; + + error = 0; + for (region = 0; region < number_of_regions; region++) { + category = power_categories[region]; + coefs_ptr = coefs + (region * region_size); + + if (category < 7) { + decoder_tree = decoder_tables[category]; + + for (i = 0; i < number_of_vectors[category]; i++) { + index = 0; + do { + if (number_of_available_bits <= 0) { + error = 1; + break; + } + + index = decoder_tree[index + next_bit (bs)]; + number_of_available_bits--; + } while ((index & 1) == 0); + + index >>= 1; + + if (error == 0 && number_of_available_bits >= 0) { + for (j = 0; j < vector_dimension[category]; j++) { + decoded_value = + mlt_quant[category][index & ((1 << index_table[category]) - 1)]; + index >>= index_table[category]; + + if (decoded_value != 0) { + if (next_bit (bs) == 0) + decoded_value *= -decoder_standard_deviation[region]; + else + decoded_value *= decoder_standard_deviation[region]; + number_of_available_bits--; + } + + *coefs_ptr++ = decoded_value * scale_factor; + } + } else { + error = 1; + break; + } + } + + if (error == 1) { + for (j = region + 1; j < number_of_regions; j++) + power_categories[j] = 7; + category = 7; + } + } + + + coefs_ptr = coefs + (region * region_size); + + if (category == 5) { + i = 0; + for (j = 0; j < region_size; j++) { + if (*coefs_ptr != 0) { + i++; + if (fabs (*coefs_ptr) > 2.0 * decoder_standard_deviation[region]) { + i += 3; + } + } + coefs_ptr++; + } + + noise = decoder_standard_deviation[region] * noise_category5[i]; + } else if (category == 6) { + i = 0; + for (j = 0; j < region_size; j++) { + if (*coefs_ptr++ != 0) + i++; + } + + noise = decoder_standard_deviation[region] * noise_category6[i]; + } else if (category == 7) { + noise = decoder_standard_deviation[region] * noise_category7; + } else { + noise = 0; + } + + coefs_ptr = coefs + (region * region_size); + + if (category == 5 || category == 6 || category == 7) { + dw1 = get_dw (decoder); + dw2 = get_dw (decoder); + + for (j = 0; j < 10; j++) { + if (category == 7 || *coefs_ptr == 0) { + if ((dw1 & 1)) + *coefs_ptr = noise; + else + *coefs_ptr = -noise; + } + coefs_ptr++; + dw1 >>= 1; + + if (category == 7 || *coefs_ptr == 0) { + if ((dw2 & 1)) + *coefs_ptr = noise; + else + *coefs_ptr = -noise; + } + coefs_ptr++; + dw2 >>= 1; + } + } + } + + return error == 1 ? -1 : number_of_available_bits; +} diff --git a/Frameworks/g7221/g7221/libsiren/huffman.h b/Frameworks/g7221/g7221/libsiren/huffman.h new file mode 100644 index 000000000..0181a7f68 --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/huffman.h @@ -0,0 +1,42 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + +#ifndef _SIREN7_HUFFMAN_H_ +#define _SIREN7_HUFFMAN_H_ + +#include "decoder.h" + +typedef struct bitstream +{ + short current_word; + int bit_idx; + int *bitstream_ptr; +} bitstream; + +extern int compute_region_powers(int number_of_regions, float *coefs, int *drp_num_bits, int *drp_code_bits, int *absolute_region_power_index, int esf_adjustment); +extern int quantize_mlt(int number_of_regions, int rate_control_possibilities, int number_of_available_bits, float *coefs, int *absolute_region_power_index, int *power_categories, int *category_balance, int *region_mlt_bit_counts, int *region_mlt_bits); +extern int decode_envelope(bitstream *bs, int number_of_regions, float *decoder_standard_deviation, int *absolute_region_power_index, int esf_adjustment); +extern int decode_vector(SirenDecoder decoder, bitstream *bs, int number_of_regions, int number_of_available_bits, float *decoder_standard_deviation, int *power_categories, float *coefs, int scale_factor); + +extern void set_bitstream(bitstream *, int *stream); +extern int next_bit(bitstream *); + +#endif /* _SIREN7_HUFFMAN_H_ */ diff --git a/Frameworks/g7221/g7221/libsiren/huffman_consts.h b/Frameworks/g7221/g7221/libsiren/huffman_consts.h new file mode 100644 index 000000000..6b23f24c7 --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/huffman_consts.h @@ -0,0 +1,528 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + + +#ifndef _HUFFMAN_CONSTS_H +#define _HUFFMAN_CONSTS_H + + +static const int differential_region_power_bits[28][24] = { + {4, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 5, 7, 8, 9, 11, 11, 12, 12, 12, 12}, + {10, 8, 6, 5, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 7, 9, 11, 12, 13, 15, 15, 15, 16, 16}, + {12, 10, 8, 6, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 4, 4, 5, 5, 7, 9, 11, 13, 14, 14}, + {13, 10, 9, 9, 7, 7, 5, 5, 4, 3, 3, 3, 3, 3, 4, 4, 4, 5, 7, 9, 11, 13, 13, 13}, + {12, 13, 10, 8, 6, 6, 5, 5, 4, 4, 3, 3, 3, 3, 3, 4, 5, 5, 6, 7, 9, 11, 14, 14}, + {12, 11, 9, 8, 8, 7, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 5, 5, 7, 8, 10, 13, 14, 14}, + {15, 16, 15, 12, 10, 8, 6, 5, 4, 3, 3, 3, 2, 3, 4, 5, 5, 7, 9, 11, 13, 16, 16, 16}, + {14, 14, 11, 10, 9, 7, 7, 5, 5, 4, 3, 3, 2, 3, 3, 4, 5, 7, 9, 9, 12, 14, 15, 15}, + {9, 9, 9, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 13}, + {14, 12, 10, 8, 6, 6, 5, 4, 3, 3, 3, 3, 3, 3, 4, 5, 6, 8, 8, 9, 11, 14, 14, 14}, + {13, 10, 9, 8, 6, 6, 5, 4, 4, 4, 3, 3, 2, 3, 4, 5, 6, 8, 9, 9, 11, 12, 14, 14}, + {16, 13, 12, 11, 9, 6, 5, 5, 4, 4, 4, 3, 2, 3, 3, 4, 5, 7, 8, 10, 14, 16, 16, 16}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14}, + {13, 14, 14, 14, 10, 8, 7, 7, 5, 4, 3, 3, 2, 3, 3, 4, 5, 5, 7, 9, 11, 14, 14, 14} +}; + + +static const int differential_region_power_codes[28][24] = { + {8, 38, 18, 10, 7, 6, 3, 2, 0, 1, 7, 6, 5, 4, 11, 78, 158, 318, 1278, 1279, 2552, 2553, 2554, 2555}, + {36, 8, 3, 5, 0, 1, 7, 6, 4, 3, 2, 5, 3, 4, 5, 19, 74, 150, 302, 1213, 1214, 1215, 2424, 2425}, + {2582, 644, 160, 41, 5, 11, 7, 5, 4, 1, 0, 6, 4, 7, 3, 6, 4, 21, 81, 323, 1290, 5167, 10332, 10333}, + {2940, 366, 181, 180, 47, 46, 27, 10, 8, 5, 1, 0, 3, 7, 4, 9, 12, 26, 44, 182, 734, 2941, 2942, 2943}, + {3982, 7967, 994, 249, 63, 26, 19, 18, 14, 8, 6, 1, 0, 2, 5, 7, 12, 30, 27, 125, 496, 1990, 15932, 15933}, + {3254, 1626, 407, 206, 202, 100, 30, 14, 3, 5, 3, 0, 2, 4, 2, 13, 24, 31, 102, 207, 812, 6511, 13020, 13021}, + {1110, 2216, 1111, 139, 35, 9, 3, 20, 11, 4, 2, 1, 3, 3, 1, 0, 21, 5, 16, 68, 276, 2217, 2218, 2219}, + {1013, 1014, 127, 62, 29, 6, 4, 16, 0, 1, 3, 2, 3, 1, 5, 9, 17, 5, 28, 30, 252, 1015, 2024, 2025}, + {381, 380, 372, 191, 94, 44, 16, 10, 7, 3, 1, 0, 2, 6, 9, 17, 45, 92, 187, 746, 1494, 2991, 5980, 5981}, + {3036, 758, 188, 45, 43, 10, 4, 3, 6, 4, 2, 0, 3, 7, 11, 20, 42, 44, 46, 95, 378, 3037, 3038, 3039}, + {751, 92, 45, 20, 26, 4, 12, 7, 4, 0, 4, 1, 3, 5, 5, 3, 27, 21, 44, 47, 186, 374, 1500, 1501}, + {45572, 5697, 2849, 1425, 357, 45, 23, 6, 10, 7, 2, 2, 3, 0, 4, 6, 7, 88, 179, 713, 11392, 45573, 45574, 45575}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021}, + {2511, 5016, 5018, 5017, 312, 79, 38, 36, 30, 14, 6, 0, 2, 1, 3, 5, 8, 31, 37, 157, 626, 5019, 5020, 5021} +}; + + +static const int bitcount_table_category0[196] = { + 1, 4, 6, 6, 7, 7, 8, 8, 8, 9, 9, 10, 11, 11, 4, 5, 6, 7, 7, 8, 8, + 9, 9, 9, 9, 10, 11, 11, 5, 6, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, + 12, 6, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 12, 13, 7, 7, 8, 9, 9, + 9, 10, 10, 10, 10, 11, 11, 12, 13, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, + 11, 12, 13, 14, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 15, 8, + 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 14, 15, 9, 9, 9, 10, 10, 10, + 11, 11, 12, 13, 12, 14, 15, 16, 9, 9, 10, 10, 10, 10, 11, 12, 12, 14, + 14, 16, 16, 16, 9, 9, 10, 10, 11, 11, 12, 13, 13, 14, 14, 15, 15, 16, + 10, 10, 10, 11, 11, 12, 12, 13, 15, 15, 16, 14, 15, 15, 11, 11, 11, 12, + 13, 13, 13, 15, 16, 16, 16, 16, 14, 15, 11, 11, 12, 13, 13, 14, 15, 16, + 16, 16, 16, 16, 16, 14}; + +static const int code_table_category0[196] = { + 1, 2, 1, 24, 14, 51, 9, 68, 110, 26, 218, 54, 154, 761, 3, 10, 22, 8, 58, + 22, 71, 16, 30, 50, 213, 75, 94, 632, 15, 18, 52, 23, 107, 5, 54, 63, 239, + 46, 276, 271, 851, 252, 28, 10, 12, 1, 22, 133, 191, 55, 105, 278, 317, 554, + 310, 276, 32, 50, 94, 20, 187, 219, 13, 268, 473, 445, 145, 849, 1277, 623, + 1, 14, 0, 55, 238, 121, 120, 269, 318, 530, 639, 1117, 509, 556, 24, 78, 51, + 153, 62, 308, 16, 25, 68, 1058, 428, 277, 2233, 1114, 92, 108, 141, 223, 270, + 381, 24, 212, 760, 35, 1063, 279, 1717, 3439, 7, 21, 152, 73, 309, 310, 95, 944, + 1890, 2232, 1891, 5107, 10213, 4981, 61, 62, 9, 79, 474, 475, 848, 1059, 1056, 1716, + 139, 4978, 4983, 4983, 140, 186, 76, 444, 144, 633, 1057, 838, 2237, 4472, 4473, + 10212, 10212, 4983, 74, 78, 311, 213, 850, 1062, 1119, 508, 276, 277, 4982, 4473, + 10212, 10212, 208, 70, 555, 418, 68, 510, 2552, 1115, 4980, 4979, 4982, 4982, 4473, + 10212, 215, 71, 253, 511, 839, 1718, 2488, 6876, 6877, 4979, 4979, 4982, 4982, 4473}; + + +static const int bitcount_table_category1[100] = { + 1, 4, 5, 6, 7, 8, 8, 9, 10, 10, 4, 5, 6, 7, 7, 8, 8, 9, 9, 11, 5, 5, 6, 7, 8, 8, 9, 9, + 10, 11, 6, 6, 7, 8, 8, 9, 9, 10, 11, 12, 7, 7, 8, 8, 9, 9, 10, 11, 11, 13, 8, 8, 8, + 9, 9, 10, 10, 11, 12, 14, 8, 8, 8, 9, 10, 11, 11, 12, 13, 15, 9, 9, 9, 10, 11, 12, + 12, 14, 14, 14, 9, 9, 9, 10, 11, 12, 14, 16, 14, 14, 10, 10, 11, 12, 13, 14, 16, 16, + 16, 14}; + +static const int code_table_category1[100] = { + 1, 2, 11, 27, 31, 9, 120, 31, 275, 310, 1, 0, 12, 5, 33, 54, 102, 111, 246, 448, 10, 14, + 31, 39, 59, 100, 114, 202, 485, 969, 24, 26, 36, 52, 103, 30, 120, 242, 69, 1244, 35, + 32, 14, 61, 113, 117, 233, 486, 487, 2491, 13, 12, 69, 110, 149, 35, 495, 449, 1978, + 7751, 76, 75, 122, 136, 213, 68, 623, 930, 3959, 9961, 115, 16, 107, 225, 424, 850, + 1936, 7916, 4981, 4981, 148, 154, 243, 407, 988, 851, 7750, 19920, 7916, 4981, 406, 274, + 464, 931, 3874, 7917, 19921, 19920, 19920, 7916}; + + +static const int bitcount_table_category2[64] = { + 1, 4, 5, 7, 8, 9, 10, 3, 4, 5, 7, 8, 9, 10, 5, 5, 6, 7, 8, 10, 10, 7, 6, 7, 8, 9, 10, 12, + 8, 8, 8, 9, 10, 12, 14, 8, 9, 9, 10, 11, 15, 16, 9, 10, 11, 12, 13, 16, 15, 1, 1, 1}; + +static const int code_table_category2[52] = { + 1, 0, 10, 11, 28, 62, 363, 3, 2, 9, 8, 24, 53, 352, 7, 8, 13, 25, 89, 74, 355, 10, 23, 24, + 29, 55, 354, 1449, 25, 19, 30, 52, 108, 438, 5793, 91, 36, 63, 353, 725, 11584, 23170, 180, + 75, 218, 439, 2897, 23171, 11584}; + + +static const int bitcount_table_category3[625] = { + 2, 4, 6, 8, 10, 5, 5, 6, 8, 10, 7, 8, 8, 10, 12, 9, 9, 10, 12, 15, 10, 11, 13, 16, 16, 5, 6, 8, + 10, 11, 5, 6, 8, 10, 12, 7, 7, 8, 10, 13, 9, 9, 10, 12, 15, 12, 11, 13, 16, 16, 7, 9, 10, 12, + 15, 7, 8, 10, 12, 13, 9, 9, 11, 13, 16, 11, 11, 12, 14, 16, 12, 12, 14, 16, 14, 9, 11, 12, 16, + 16, 9, 10, 13, 15, 16, 10, 11, 12, 16, 16, 13, 13, 16, 16, 16, 16, 16, 15, 16, 16, 11, 13, 16, + 16, 15, 11, 13, 15, 16, 16, 13, 13, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 4, 6, 8, + 10, 13, 6, 6, 8, 10, 13, 9, 8, 10, 12, 16, 10, 10, 11, 15, 16, 13, 12, 14, 16, 16, 5, 6, 8, 11, 13, + 6, 6, 8, 10, 13, 8, 8, 9, 11, 14, 10, 10, 12, 12, 16, 13, 12, 13, 15, 16, 7, 8, 9, 12, 16, 7, 8, + 10, 12, 14, 9, 9, 10, 13, 16, 11, 10, 12, 15, 16, 13, 13, 16, 16, 15, 9, 11, 13, 16, 16, 9, 10, + 12, 15, 16, 10, 11, 13, 16, 16, 13, 12, 16, 16, 16, 16, 16, 16, 16, 16, 11, 13, 16, 16, 16, 11, + 13, 16, 16, 16, 12, 13, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 6, 8, 11, 13, 16, 8, + 8, 10, 12, 16, 11, 10, 11, 13, 16, 12, 13, 13, 15, 16, 16, 16, 14, 16, 15, 6, 8, 10, 13, 16, 8, + 8, 10, 12, 16, 10, 10, 11, 13, 16, 13, 12, 13, 16, 16, 14, 14, 14, 16, 16, 8, 9, 11, 13, 16, 8, + 9, 11, 16, 14, 10, 10, 12, 15, 16, 12, 12, 13, 16, 16, 15, 16, 16, 16, 16, 10, 12, 15, 16, 16, + 10, 12, 12, 14, 16, 12, 12, 13, 16, 16, 14, 15, 16, 16, 16, 16, 16, 16, 16, 16, 12, 15, 15, 16, + 16, 13, 13, 16, 16, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 15, 16, 16, 16, 8, 10, 13, + 15, 16, 10, 11, 13, 16, 16, 13, 13, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 10, + 11, 15, 16, 9, 10, 12, 16, 16, 12, 12, 15, 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 9, 11, + 14, 16, 16, 10, 11, 13, 16, 16, 14, 13, 14, 16, 16, 16, 15, 15, 16, 16, 16, 16, 16, 16, 16, 11, 13, + 16, 16, 16, 11, 13, 15, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 16, + 16, 16, 16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 9, 13, + 16, 16, 16, 11, 13, 16, 16, 16, 14, 15, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 9, 13, + 15, 15, 16, 12, 13, 14, 16, 16, 16, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 11, 13, + 15, 16, 16, 12, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 15, 15, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 15, 16, 16, 13, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16}; + +static const int code_table_category3[625] = { + 3, 8, 46, 145, 228, 4, 8, 47, 28, 455, 89, 2, 180, 5, 1335, 250, 12, 644, 1311, 139, 729, 251, 870, + 2172, 2211, 5, 23, 112, 334, 1469, 21, 3, 5, 111, 2014, 88, 79, 152, 124, 2685, 297, 48, 110, 1310, + 149, 501, 1231, 153, 2267, 2569, 57, 13, 653, 2587, 143, 75, 124, 118, 2611, 5242, 61, 50, 253, 3633, + 2216, 476, 39, 57, 1926, 2236, 2586, 1329, 1920, 2566, 1926, 296, 233, 2590, 2240, 2217, 253, 613, + 867, 144, 318, 614, 252, 2589, 2242, 2218, 872, 866, 2187, 2296, 2155, 2568, 2227, 150, 2567, 2296, + 199, 2686, 2160, 2290, 19145, 232, 2680, 128, 2192, 2212, 2684, 793, 2281, 2223, 2242, 1934, 2165, + 2146, 2291, 2296, 2222, 2189, 2187, 2296, 2296, 6, 4, 82, 725, 3632, 15, 21, 56, 599, 148, 3, 162, + 42, 411, 2301, 735, 654, 930, 137, 2586, 869, 1334, 1931, 2300, 2213, 9, 22, 146, 1290, 5240, 5, 12, + 53, 630, 875, 80, 9, 8, 86, 2002, 210, 117, 56, 2019, 2162, 146, 397, 868, 131, 2151, 77, 160, 365, + 2610, 2252, 59, 54, 41, 2591, 1928, 226, 14, 121, 5792, 2295, 1197, 728, 408, 130, 2157, 3635, 155, + 2573, 2587, 130, 314, 64, 144, 2173, 2176, 115, 30, 409, 153, 2590, 631, 26, 4787, 2221, 2174, 2683, + 1863, 2572, 319, 2150, 2177, 2194, 2571, 2257, 319, 65, 145, 2251, 2156, 2161, 909, 864, 2193, 2197, + 2246, 2588, 5797, 156, 2258, 2221, 2158, 2199, 2214, 2152, 319, 2188, 2264, 2572, 319, 319, 30, 117, + 219, 865, 2263, 147, 127, 239, 410, 2247, 27, 324, 1468, 2681, 2180, 1328, 5241, 147, 142, 2237, 2241, + 2245, 1921, 2262, 142, 41, 11, 505, 2682, 2591, 0, 26, 229, 2015, 2577, 464, 98, 87, 5243, 2166, 149, + 2016, 5244, 2190, 2198, 9573, 11598, 11599, 2235, 2190, 144, 298, 1004, 5245, 2277, 156, 104, 254, 2560, + 1922, 612, 325, 2017, 129, 2588, 2608, 1330, 871, 2144, 2145, 132, 2147, 2148, 2149, 2144, 119, 1331, + 133, 2153, 2154, 211, 58, 2609, 1923, 2159, 510, 163, 5246, 2163, 2164, 1924, 134, 2167, 2168, 2168, 2169, + 2170, 2171, 2168, 2168, 1332, 135, 136, 2175, 2153, 150, 873, 2178, 2179, 1923, 1925, 2181, 2182, 2183, + 2163, 2184, 2185, 2186, 2168, 2168, 1924, 134, 2167, 2168, 2168, 58, 326, 2687, 138, 2191, 31, 66, 874, + 2195, 2196, 151, 152, 1927, 2200, 2201, 2202, 2203, 2204, 2205, 2206, 2207, 2208, 2209, 2210, 2205, 55, + 103, 1230, 140, 2215, 118, 15, 1333, 2219, 2220, 2018, 511, 141, 2224, 2225, 2226, 1929, 2228, 2229, 2230, + 2231, 2232, 2233, 2234, 2229, 366, 1005, 1930, 2238, 2239, 12, 1006, 5247, 2243, 2244, 1932, 3634, 1933, + 2248, 2249, 2250, 145, 146, 2253, 2253, 2254, 2255, 2256, 2253, 2253, 1291, 5793, 2259, 2260, 2261, 477, + 5794, 147, 2265, 2266, 5795, 2268, 2269, 2270, 2270, 2271, 2272, 2273, 2274, 2274, 2275, 2276, 2273, 2274, + 2274, 148, 2278, 2279, 2280, 2260, 1935, 2282, 2283, 2284, 2265, 2285, 2286, 2287, 2270, 2270, 2288, 2289, + 2273, 2274, 2274, 2271, 2272, 2273, 2274, 2274, 233, 5796, 2292, 2293, 2294, 1292, 3724, 2297, 2298, 2299, + 2000, 151, 2302, 2303, 2200, 152, 2561, 2562, 2563, 2205, 2564, 2565, 2204, 2205, 2205, 363, 154, 154, 155, + 2570, 59, 3725, 2001, 2574, 2575, 2576, 157, 2578, 2579, 2224, 2580, 2581, 2582, 2583, 2229, 2584, 2585, 2228, + 2229, 2229, 654, 5798, 158, 2589, 2238, 2392, 2003, 2592, 2593, 2243, 2594, 2595, 2596, 2597, 2248, 2598, 2599, + 2600, 2253, 2253, 2250, 145, 146, 2253, 2253, 2601, 2602, 2603, 2604, 2260, 2605, 2606, 2607, 6336, 2265, 6337, + 6338, 6339, 2270, 2270, 6340, 6341, 2273, 2274, 2274, 2271, 2272, 2273, 2274, 2274, 6342, 6343, 2259, 2260, + 2260, 38288, 38289, 147, 2265, 2265, 5795, 2268, 2269, 2270, 2270, 2271, 2272, 2273, 2274, 2274, 2271, 2272, + 2273, 2274, 2274}; + + +static const int bitcount_table_category4[256] = { + 2, 4, 7, 10, 4, 5, 7, 10, 7, 8, 10, 14, 11, 11, 15, 15, 4, 5, 9, + 12, 5, 5, 8, 12, 8, 7, 10, 15, 11, 11, 15, 15, 7, 9, 12, 15, 8, 8, + 12, 15, 10, 10, 13, 15, 14, 14, 15, 13, 11, 13, 15, 15, 11, 13, 15, + 15, 14, 15, 15, 13, 15, 15, 13, 13, 4, 5, 9, 13, 5, 6, 9, 13, 9, 9, + 11, 15, 14, 13, 15, 15, 4, 6, 9, 12, 5, 6, 9, 13, 9, 8, 11, 15, 13, + 12, 15, 15, 7, 9, 12, 15, 7, 8, 11, 15, 10, 10, 14, 15, 14, 15, 15, + 14, 10, 12, 15, 15, 11, 13, 15, 15, 15, 15, 15, 14, 15, 15, 14, 14, + 6, 9, 13, 14, 8, 9, 12, 15, 12, 12, 15, 15, 15, 15, 15, 15, 7, 9, 13, + 15, 8, 9, 12, 15, 11, 12, 15, 15, 15, 15, 15, 15, 9, 11, 15, 15, 9, + 11, 15, 15, 14, 14, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 14, 15, + 15, 15, 15, 15, 15, 15, 14, 14, 15, 15, 9, 12, 15, 15, 12, 13, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 10, 12, 15, 15, 12, 14, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 14, 14, + 15, 15, 14, 14, 15, 15}; + +static const int code_table_category4[256] = { + 1, 2, 4, 572, 10, 0, 69, 712, 91, 10, 46, 9182, 1426, 1430, 30172, 30194, + 9, 28, 22, 2258, 16, 25, 142, 2179, 15, 111, 719, 1521, 1131, 1437, 1520, + 30196, 88, 283, 3803, 30193, 13, 236, 2856, 30166, 545, 951, 5709, 1522, + 3241, 9180, 30179, 5709, 1088, 4356, 30410, 30175, 1146, 377, 30162, 30163, + 8715, 30176, 30165, 5709, 30197, 30184, 5709, 5709, 1, 23, 28, 5710, 26, 14, + 29, 7538, 102, 103, 1429, 1524, 3237, 7060, 30401, 30201, 15, 13, 470, 3768, + 24, 15, 281, 5747, 24, 181, 1128, 30206, 5711, 3531, 30156, 30158, 116, 100, + 2260, 30187, 119, 234, 1764, 30171, 716, 883, 9183, 30164, 3236, 1528, 30180, + 9183, 885, 2870, 1532, 30160, 1431, 5708, 30192, 30205, 30402, 30168, 30173, + 9183, 30157, 30161, 9183, 9183, 54, 25, 1621, 15211, 180, 287, 2261, 30198, 808, + 811, 30411, 30413, 30414, 22986, 22987, 30411, 24, 273, 376, 30159, 137, 280, + 2871, 1523, 1768, 2259, 1525, 30167, 1526, 30169, 30170, 1525, 443, 1434, 1527, + 30174, 474, 1769, 30177, 30178, 3238, 3239, 30181, 30181, 30182, 30183, 30181, + 30181, 3240, 30185, 30186, 1527, 9181, 30188, 30189, 30177, 30190, 30191, 30181, + 30181, 3238, 3239, 30181, 30181, 440, 2857, 1529, 30195, 2294, 7061, 1530, 30199, + 30200, 1531, 30202, 30411, 30203, 30204, 30411, 30411, 203, 2872, 30207, 30400, + 189, 11492, 30403, 30404, 30405, 30406, 30407, 1525, 30408, 30409, 1525, 1525, + 8714, 1533, 30412, 1527, 1534, 1535, 30415, 30177, 30416, 30417, 30181, 30181, + 3238, 3239, 30181, 30181, 30418, 30419, 1527, 1527, 30420, 30421, 30177, 30177, + 3238, 3239, 30181, 30181, 3238, 3239, 30181, 30181}; + + +static const int bitcount_table_category5[256] = { + 2, 4, 8, 4, 5, 9, 9, 10, 14, 4, 6, 11, 5, 6, 12,10, 11, 15, 9, 11, 15, 10, 13, 15, + 14, 15, 6, 4, 6, 12, 6, 7, 12, 12, 12, 15, 5, 7, 13, 6, 7, 13, 12, 13, 15, 10, 12, + 15, 11, 13, 15, 15, 15, 7, 8, 13, 15, 11, 12, 15, 15, 15, 7, 10, 13, 15, 12, 15, 15, + 15, 15, 7, 15, 15, 7, 15, 15, 7, 6, 7, 7, 4, 5, 11, 5, 7, 12, 11, 12, 15, 6, 7, 13, 7, + 8, 14, 12, 14, 15, 11, 13, 15, 12, 13, 15, 15, 15, 8, 5, 6, 13, 7, 8, 15, 12, 14, 15, + 6, 8, 14, 7, 8, 15, 14, 15, 15, 12, 12, 15, 12, 13, 15, 15, 15, 8, 9, 13, 15, 12, 13, + 15, 15, 15, 8, 11, 13, 15, 13, 13, 15, 15, 15, 8, 14, 15, 8, 15, 15, 8, 7, 8, 8, 8, 10, + 15, 11, 12, 15, 15, 15, 7, 10, 12, 15, 12, 13, 15, 15, 15, 8, 14, 15, 7, 15, 15, 8, 7, + 8, 8, 8, 12, 15, 12, 13, 15, 15, 15, 8, 11, 13, 15, 13, 15, 15, 15, 15, 8, 15, 15, 8, + 15, 15, 8, 7, 8, 8, 14, 15, 6, 15, 15, 8, 7, 8, 8, 15, 15, 8, 15, 15, 8, 7, 8, 8, 6, + 8, 8, 7, 8, 8, 7, 8, 8}; + +static const int code_table_category5[243] = { + 0, 5, 220, 10, 16, 443, 390, 391, 14333, 11, 26, 1566, 26, 54, 3135, 508, 1558, 28581, + 255, 1782, 28599, 885, 6208, 28578, 14335, 28579, 54, 9, 35, 3129, 27, 68, 3537, 1562, + 3568, 28610, 25, 62, 4078, 58, 118, 7763, 3107, 7758, 28563, 778, 3131, 28598, 780, 7123, + 28630, 28593, 28586, 118, 243, 6210, 28614, 1018, 3567, 28601, 28611, 28570, 68, 388, 6256, + 28619, 1559, 28562, 28606, 28565, 28591, 118, 28594, 28571, 62, 28618, 28590, 118, 58, + 118, 118, 4, 28, 1781, 31, 60, 3134, 1938, 3882, 28574, 25, 96, 7757, 49, 126, 14244, + 3883, 14334, 28613, 1769, 4077, 28602, 3106, 7756, 28582, 28621, 28566, 126, 14, 61, 4079, + 61, 138, 28491, 3536, 8153, 28573, 49, 96, 12442, 119, 240, 28490, 12443, 28560, 28561, 3111, + 3580, 28564, 3130, 7759, 28567, 28568, 28569, 240, 444, 6209, 28572, 3569, 6211, 28575, 28576, + 28577, 138, 778, 7760, 28580, 7761, 7762, 28583, 28584, 28585, 240, 14319, 28587, 96, 28588, 28589, + 240, 119, 240, 240, 139, 968, 28592, 1554, 3581, 28595, 28596, 28597, 60, 971, 3560, 28600,3582, + 7132, 28603, 28604, 28605, 126, 14332, 28607, 96, 28608, 28609, 126, 49, 126, 126, 241, 1558, 28612, + 1563, 6257, 28615, 28616, 28617, 138, 1559, 7133, 28620, 6220, 28622, 28623, 28624, 28625, 240, 28626, + 28627, 96, 28628, 28629, 240, 119, 240, 240, 8152, 28631, 61, 28632, 28633, 138, 61, 138, 138, 28634, + 28635, 96, 28636, 28637, 240, 119, 240, 240, 49, 96, 96, 119, 240, 240, 119, 240, 240}; + + +static const int bitcount_table_category6[32] = {1, 4, 4, 6, 4, 6, 6, 8, 4, 6, 6, 8, 6, 9, 8, 10, 4, 6, 7, 8, 6, 9, 8, 11, 6, 9, 8, 10, 8, 10, 9, 11}; + +static const int code_table_category6[32] = {1, 2, 4, 2, 5, 29, 24, 101, 3, 31, 28, 105, 3, 5, 102, 424, 1, 30, 0, 107, 27, 200, 103, 806, 1, 4, 104, 402, 3, 425, 213, 807}; + + + +static const int *bitcount_tables[7] = { + bitcount_table_category0, + bitcount_table_category1, + bitcount_table_category2, + bitcount_table_category3, + bitcount_table_category4, + bitcount_table_category5, + bitcount_table_category6}; + +static const int *code_tables[7] = { + code_table_category0, + code_table_category1, + code_table_category2, + code_table_category3, + code_table_category4, + code_table_category5, + code_table_category6}; + + + + +static const int differential_decoder_tree[27][24][2] = { + {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, -12}, {-11, -10}, {-8, -9}, {-7, -6}, {-13, 12}, {-5, -4}, {0, 13}, {-3, -14}, {-2, 14}, {-1, 15}, {-15, 16}, {-16, 17}, {-17, 18}, {19, 20}, {21, 22}, {-18, -19}, {-20, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {-10, -9}, {-8, -11}, {-7, -6}, {9, -5}, {10, -12}, {-4, 11}, {-13, -3}, {12, -2}, {13, -14}, {-1, 14}, {15, -15}, {0, 16}, {-16, 17}, {-17, 18}, {-18, 19}, {20, 21},{22, -19}, {-20, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {-12, 11}, {-11, -13}, {-10, -9}, {12, -14}, {-8, -7}, {-15, -6}, {13, -5}, {-16, -4}, {14, -17}, {15, -3}, {16, -18}, {-2, 17}, {18, -19}, {-1, 19}, {-20, 20}, {0, 21}, {22, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, 6}, {-11, -10}, {7, -12}, {8, -9}, {9, -13}, {-14, 10}, {-8, -15}, {-16, 11}, {-7, 12}, {-17, -6}, {13, 14}, {-18, 15}, {-5, -4}, {16, 17}, {-3, -2}, {-19, 18}, {-1, 19}, {-20, 20}, {21, 22}, {0, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, 6}, {-12, -11}, {-13, 7}, {8, -14}, {-10, 9}, {10, -15}, {-9, 11}, {-8, 12}, {-16, 13}, {-7, -6}, {-17, 14}, {-5, -18}, {15, -4}, {16, -19}, {17, -3}, {-20, 18}, {-2, 19}, {-21, 20}, {0, 21}, {22, -1}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, 6}, {-11, 7}, {-12, -10}, {-13, -9}, {8, 9}, {-14, -8}, {10, -15}, {-7, 11}, {-16, 12}, {-6, -17}, {13, 14}, {-5, 15}, {-18, 16}, {-4, 17}, {-3, -19}, {18, -2}, {-20, 19}, {-1, 20}, {0, 21}, {22, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, -12}, {6, -11}, {-10, -13}, {-9, 7}, {8, -14}, {9, -8}, {-15, 10}, {-7, -16}, {11, -6}, {12, -17}, {13, -5}, {-18, 14}, {15, -4}, {-19, 16}, {17, -3}, {-20, 18}, {19, 20}, {21, 22}, {0, -2}, {-1, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, -12}, {6, -13}, {-11, -10}, {7, -14}, {8, -9}, {9, -15}, {-8, 10}, {-7, -16}, {11, 12}, {-6, -17}, {-5, 13}, {14, 15}, {-18, -4}, {-19, 16}, {-3, 17}, {18, -2}, {-20, 19}, {20, 21}, {22, 0}, {-1, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, 6}, {-11, -10}, {-12, -9}, {7, 8}, {-13, -8}, {9, -14}, {-7, 10}, {-6, -15}, {11, 12}, {-5, -16}, {13, 14}, {-17, 15}, {-4, 16}, {17, -18}, {18, -3}, {-2, 19}, {-1, 0}, {-19, 20}, {-20, 21}, {22, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, 6}, {-11, 7}, {-10, -12}, {-9, 8}, {-8, -13}, {9, -7}, {10, -14}, {-6, 11}, {-15, 12}, {-5, 13}, {-16, -4}, {14, 15}, {-17, -3}, {-18, 16}, {17, -19}, {-2, 18}, {-20, 19}, {-1, 20}, {21, 22}, {0, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, -12}, {6, -11}, {7, 8}, {-10, -13}, {-9, 9}, {-8, -14}, {10, -7}, {11, -15}, {-6, 12}, {-5, 13}, {-4, -16}, {14, 15}, {-3, -17}, {16, 17}, {-18, -2}, {18, -19}, {-1, 19}, {-20, 20}, {-21, 21}, {22, 0}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {5, -12}, {-13, 6}, {-11, 7}, {-14, 8}, {-10, 9}, {-15, -9}, {-8, 10}, {-7, -16}, {11, -6}, {12, -5}, {-17, 13}, {14, -18}, {15, -4}, {16, -19}, {17, -3}, {18, -2}, {19, -1}, {-20, 20}, {21, 22}, {0, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}, + {{1, 2}, {3, 4}, {-12, 5}, {-11, -13}, {6, -14}, {-10, 7}, {8, -15}, {-9, 9}, {-16, 10}, {-8, -17}, {11, 12}, {-7, -18}, {-6, 13}, {14, -5}, {15, -19}, {-4, 16}, {-20, 17}, {18, 19}, {20, 21}, {22, 0}, {-1, -3}, {-2, -21}, {-22, -23}, {-32, -32}}}; + + + +static const float mlt_quant[7][14] = { + { 0.0f, 0.392f, 0.761f, 1.120f, 1.477f, 1.832f, 2.183f, 2.541f, 2.893f, 3.245f, 3.598f, 3.942f, 4.288f, 4.724f}, + { 0.0f, 0.544f, 1.060f, 1.563f, 2.068f, 2.571f, 3.072f, 3.562f, 4.070f, 4.620f, 0.0f, 0.0f, 0.0f, 0.0f}, + { 0.0f, 0.746f, 1.464f, 2.180f, 2.882f, 3.584f, 4.316f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, + { 0.0f, 1.006f, 2.000f, 2.993f, 3.985f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, + { 0.0f, 1.321f, 2.703f, 3.983f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, + { 0.0f, 1.657f, 3.491f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, + { 0.0f, 1.964f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}}; + + +static const int decoder_tree0[360] = { + 2, 1, 4, 6, 8, 10, 12, 14, 16, 18, 33, 3, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 35, 40, 42, 44, 46, 5, 48, 65, 50, 52, 54, 56, 58, 60, + 62, 64, 37, 66, 67, 68, 97, 70, 72, 74, 7, 76, 78, 80, 82, 84, 86, 88, + 99, 90, 39, 92, 94, 96, 129, 98, 9, 100, 102, 104, 106, 108, 110, 112, 41, 161, + 69, 114, 116, 118, 131, 120, 122, 11, 124, 126, 128, 193, 130, 132, 71, 134, 43, 136, + 138, 140, 163, 101, 13, 142, 144, 146, 148, 150, 152, 154, 225, 156, 158, 195, 160, 162, + 45, 164, 15, 166, 73, 168, 170, 133, 47, 172, 257, 174, 176, 178, 75, 103, 180, 165, + 182, 17, 227, 184, 105, 49, 135, 186, 289, 188, 259, 190, 192, 194, 196, 198, 291, 77, + 200, 202, 197, 107, 204, 19, 51, 229, 206, 167, 208, 210, 212, 214, 21, 79, 81, 109, + 216, 218, 220, 222, 53, 137, 224, 199, 226, 323, 321, 169, 228, 111, 230, 232, 139, 261, + 234, 83, 236, 201, 238, 240, 293, 242, 353, 231, 141, 244, 246, 113, 23, 355, 85, 248, + 55, 115, 250, 263, 252, 254, 203, 171, 256, 258, 233, 235, 143, 357, 325, 260, 295, 262, + 173, 145, 177, 87, 264, 327, 267, 266, 268, 175, 270, 272, 117, 297, 274, 265, 147, 179, + 205, 276, 207, 237, 269, 278, 57, 59, 387, 209, 280, 282, 149, 329, 385, 284, 25, 286, + 239, 119, 288, 27, 290, 292, 299, 294, 359, 89, 296, 298, 419, 181, 300, 331, 271, 417, + 211, 361, 151, 389, 241, 302, 304, 303, 306, 308, 421, 91, 310, 312, 391, 314, 121, 316, + 333, 318, 275, 213, 301, 243, 183, 335, 320, 363, 322, 215, 324, 393, 273, 337, 153, 326, + 423, 365, 328, 367, 247, 395, 185, 123, 330, 425, 245, 155, 332, 334, 305, 397, 336, 277, + 217, 338, 340, 339, 427, 342, 344, 346, 307, 399, 187, 348, 309, 341, 350, 369, 279, 311, + 429, 249, 219, 352, 354, 356, 358, 431, 373, 401, 371, 313, 281, 433, 343, 403, 251, 283}; + + +static const int decoder_tree1[188] = { + 2, 1, 4, 6, 8, 10, 12, 14, 16, 3, 33, 18, 20, 22, 24, 26, 35, 28, 30, + 32, 34, 36, 5, 65, 38, 40, 37, 42, 44, 46, 67, 48, 50, 52, 54, 56, 58, + 60, 7, 62, 39, 97, 64, 69, 66, 99, 68, 70, 72, 74, 76, 78, 80, 129, 41, + 131, 82, 9, 71, 84, 86, 101, 88, 90, 92, 94, 96, 161, 43, 11, 73, 98, 103, + 100, 163, 102, 104, 106, 108, 133, 110, 105, 112, 75, 114, 45, 13, 116, 165, 118, 195, + 135, 193, 120, 77, 122, 47, 124, 167, 225, 126, 79, 107, 227, 128, 137, 197, 15, 130, + 169, 199, 132, 109, 134, 17, 139, 49, 136, 229, 138, 140, 81, 259, 142, 144, 171, 146, + 141, 148, 111, 150, 201, 231, 152, 51, 257, 289, 154, 19, 113, 156, 261, 158, 203, 173, + 263, 143, 160, 291, 235, 83, 162, 233, 265, 164, 205, 166, 293, 145, 168, 175, 177, 237, + 115, 295, 170, 207, 172, 267, 174, 176, 297, 147, 178, 180, 269, 182, 271, 209, 299, 239, + 179, 184, 301, 241, 211, 0, 0}; + +static const int decoder_tree2[96] = { + 2, 1, 4, 6, 8, 10, 12, 3, 17, 14, 19, 16, 18, 20, 22, 24, 26, 5, 21, + 35, 33, 28, 30, 32, 34, 36, 38, 37, 40, 23, 51, 42, 7, 49, 44, 46, 48, 50, + 39, 53, 52, 54, 56, 25, 67, 9, 58, 60, 65, 55, 41, 62, 64, 69, 66, 11, 27, + 68, 57, 83, 70, 71, 81, 43, 72, 74, 13, 76, 85, 29, 73, 78, 99, 59, 87, 101, + 80, 97, 45, 82, 84, 75, 89, 61, 86, 103, 88, 77, 90, 105, 91, 92, 107, 93, 0, 0}; + +static const int decoder_tree3[1040] = { + 2, 4, 6, 8, 10, 1, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 3, 36, + 1025, 38, 40, 42, 44, 46, 48, 50, 129, 17, 52, 54, 1153, 19, 56, 58, 60, 62, 64, + 66, 68, 145, 70, 72, 74, 76, 78, 1169, 1027, 147, 80, 82, 1171, 84, 86, 131, 88, 1155, + 1043, 1041, 90, 92, 5, 94, 96, 98, 100, 102, 104, 21, 106, 108, 2049, 2177, 110, 112, 114, + 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 33, 144, 163, 146, 148, + 150, 152, 154, 161, 156, 35, 158, 1297, 160, 162, 273, 257, 164, 166, 149, 168, 1281, 170, 172, + 2193, 174, 176, 178, 1299, 180, 1045, 182, 184, 1173, 186, 3201, 188, 190, 192, 194, 2195, 1187, 23, + 2179, 196, 7, 198, 275, 200, 2051, 202, 2065, 204, 206, 1029, 1185, 208, 210, 1157, 37, 3073, 2067, + 133, 212, 214, 2321, 216, 165, 218, 1059, 220, 1283, 222, 2305, 224, 226, 228, 230, 259, 232, 234, + 2323, 236, 1409, 1057, 1315, 238, 240, 242, 244, 246, 1425, 248, 1313, 250, 252, 254, 256, 258, 260, + 289, 262, 264, 1189, 266, 268, 179, 151, 270, 272, 274, 276, 278, 291, 280, 282, 9, 385, 284, + 286, 177, 49, 401, 1061, 288, 290, 292, 51, 294, 296, 298, 300, 302, 304, 25, 306, 2083, 39, + 308, 310, 3329, 167, 312, 314, 1175, 316, 318, 1203, 135, 320, 322, 324, 326, 328, 2211, 2307, 330, + 1301, 332, 334, 1047, 336, 338, 2449, 3217, 340, 1427, 2209, 53, 342, 2339, 3345, 344, 346, 348, 403, + 181, 4097, 2197, 350, 2181, 1285, 1317, 1031, 352, 354, 356, 3089, 358, 360, 4225, 277, 362, 364, 366, + 368, 2069, 370, 3203, 293, 1201, 305, 372, 3219, 307, 2433, 374, 376, 378, 380, 2081, 1411, 382, 384, + 3075, 1443, 513, 386, 387, 388, 390, 1331, 261, 392, 394, 396, 398, 400, 1441, 1075, 67, 1159, 402, + 404, 406, 408, 410, 412, 414, 3347, 2325, 416, 65, 418, 420, 422, 424, 426, 2053, 193, 1073, 428, + 430, 432, 1537, 1329, 2337, 2213, 434, 417, 183, 41, 436, 438, 440, 442, 444, 446, 448, 450, 195, + 2435, 452, 2085, 1063, 1191, 454, 456, 458, 460, 419, 2071, 1553, 3091, 55, 137, 462, 464, 466, 468, + 470, 472, 474, 476, 478, 2309, 4113, 480, 482, 484, 486, 2451, 2465, 1205, 153, 488, 490, 492, 494, + 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 1333, 526, 1555, 2467, + 2227, 3205, 3331, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 529, 309, 1303, 3473, 3457, + 389, 1569, 1445, 1077, 69, 2199, 1539, 4353, 550, 552, 554, 556, 558, 560, 562, 1459, 4241, 3221, 1429, + 2341, 279, 3475, 169, 564, 545, 3105, 323, 2353, 2097, 3235, 421, 2229, 3107, 3233, 566, 568, 570, 572, + 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 2099, 1091, 531, 2437, 4227, 405, 197, + 263, 1287, 2577, 1049, 1571, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, + 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 1345, 1219, 3077, 1457, 2225, 2579, 515, 2561, + 2469, 433, 1221, 2183, 4243, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 1217, 3333, 3093, 435, 321, + 4369, 1089, 2055, 4099, 3361, 1319, 547, 1161, 1177, 672, 2355, 4115, 1413, 4257, 3349, 2453, 3109, 2357, 2215, 3363, + 1079, 1207, 311, 1033, 1347, 1065, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, + 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, + 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, + 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 2593, 2565, 4261, + 3253, 437, 325, 3489, 2311, 4259, 1431, 2087, 2563, 295, 2343, 449, 199, 265, 2201, 4371, 1193, 816, 533, 1557, + 2581, 2241, 3365, 3491, 3603, 549, 2101, 1461, 1093, 2117, 3459, 3079, 4481, 3095, 2327, 3461, 4129, 3249, 1447, 2471, + 2231, 71, 4497, 2609, 1289, 393, 3251, 2073, 3097, 2371, 1305, 2089, 818, 820, 822, 824, 826, 828, 830, 832, + 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, + 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, + 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, + 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, + 994, 996, 998, 1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024, 1026, 1028, 1030, 1032, + 1034, 1036, 4161, 4273, 3507, 3493, 4517, 2497, 1573, 2597, 3621, 4531, 4627, 3523, 3125, 4149, 4529, 3139, 4515, 451, + 4277, 2113, 4163, 4499, 3381, 4405, 1473, 4373, 2485, 3509, 565, 1589, 2613, 3585, 3123, 4403, 3141, 4147, 563, 2245, + 3269, 4357, 1349, 2373, 3397, 453, 1477, 2501, 2481, 579, 1601, 3477, 4103, 3265, 2243, 1587, 3207, 4231, 3267, 4501, + 1475, 3335, 4359, 391, 1415, 2439, 3463, 4487, 519, 1543, 2567, 3591, 4609, 4289, 4611, 2499, 4119, 4385, 4145, 4401, + 3223, 4247, 3379, 577, 3393, 3351, 4375, 407, 1585, 2455, 3479, 4503, 535, 1559, 2583, 3607, 3605, 4513, 4485, 3111, + 4135, 3121, 517, 3377, 3239, 4263, 1541, 4291, 4229, 3367, 4391, 423, 2115, 4131, 3495, 551, 1575, 2599, 3635, 3395, + 2103, 3127, 4151, 3589, 4101, 1603, 3255, 4279, 3601, 1335, 2359, 3383, 439, 1463, 2487, 3511, 567, 1591, 4133, 1095, + 2119, 3143, 2369, 1223, 2247, 3271, 327, 1351, 2375, 455, 1479, 3137, 3521, 2057, 3081, 4105, 4387, 3505, 2185, 3209, + 4233, 3587, 4355, 2313, 3337, 3237, 1417, 2441, 3465, 521, 1545, 3617, 3633, 561, 4625, 4121, 2611, 2483, 2595, 3225, + 4249, 281, 4245, 2329, 3353, 409, 1433, 2457, 3481, 537, 1561, 4483, 3619, 4389, 3113, 4275, 4117, 2217, 3241, 297, + 1321, 2345, 3369, 425, 1449, 2473, 57, 1081, 2105, 3129, 185, 1209, 2233, 3257, 313, 1337, 2361, 441, 1465, 73, + 1097, 201, 1225, 0, 0}; + + +static const int decoder_tree4[416] = { + 2, 4, 6, 1, 8, 10, 12, 14, 16, 18, 20, 22, 24, 3, 129, 26, 28, 9, 33, 30, 32, + 34, 36, 11, 161, 38, 40, 42, 41, 44, 46, 131, 43, 169, 35, 48, 137, 50, 52, 54, 56, 139, + 163, 171, 58, 60, 62, 64, 5, 66, 68, 70, 257, 72, 74, 76, 13, 78, 80, 289, 82, 84, 17, + 86, 88, 65, 90, 201, 19, 92, 94, 51, 193, 96, 98, 49, 100, 73, 102, 104, 106, 45, 108, 110, + 297, 112, 114, 116, 37, 203, 118, 120, 179, 122, 177, 124, 265, 126, 75, 133, 259, 291, 147, 128, 67, + 195, 130, 141, 173, 299, 132, 145, 134, 165, 136, 138, 140, 142, 7, 144, 146, 21, 267, 148, 53, 150, + 321, 152, 154, 15, 156, 81, 158, 160, 385, 162, 417, 164, 166, 168, 83, 170, 172, 329, 174, 211, 176, + 27, 178, 180, 182, 209, 184, 186, 188, 190, 25, 192, 331, 194, 196, 105, 57, 198, 97, 200, 202, 323, + 225, 59, 149, 204, 206, 233, 307, 208, 77, 181, 210, 212, 214, 216, 218, 220, 222, 47, 224, 226, 69, + 228, 230, 197, 232, 425, 393, 205, 275, 293, 39, 234, 236, 238, 305, 135, 155, 301, 143, 240, 242, 235, + 395, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 273, 269, 185, 264, 266, 268, 270, 272, 274, 276, + 261, 153, 278, 280, 282, 187, 337, 387, 107, 284, 427, 227, 167, 419, 286, 288, 290, 292, 294, 296, 298, + 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 115, + 99, 85, 213, 29, 113, 23, 89, 241, 61, 449, 339, 175, 340, 342, 344, 346, 348, 350, 352, 354, 356, + 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, + 400, 402, 404, 406, 408, 410, 412, 414, 389, 361, 457, 465, 429, 451, 333, 109, 277, 243, 263, 295, 199, + 283, 151, 55, 183, 229, 357, 363, 123, 491, 397, 411, 251, 313, 441, 467, 345, 433, 461, 219, 237, 365, + 435, 353, 347, 405, 409, 217, 309, 437, 369, 371, 341, 117, 245, 249, 157, 285, 403, 189, 317, 93, 221, + 315, 401, 481, 391, 489, 121, 421, 423, 71, 483, 327, 103, 231, 443, 459, 271, 399, 355, 91, 303, 431, + 79, 207, 335, 111, 239, 281, 325, 279, 453, 101, 311, 87, 215, 31, 159, 63, 191}; + +static const int decoder_tree5[384] = { + 2, 4, 1, 6, 8, 10, 12, 14, 16, 18, 20, 22, 3, 513, 24, 26, 28, 9, 129, 33, 30, + 32, 34, 36, 38, 40, 11, 42, 641, 44, 46, 41, 161, 48, 515, 50, 52, 131, 54, 35, 545, 137, + 56, 58, 60, 521, 62, 43, 673, 64, 169, 66, 68, 523, 70, 163, 643, 139, 553, 72, 649, 74, 547, + 76, 78, 80, 681, 171, 82, 84, 555, 86, 675, 88, 651, 5, 90, 92, 1025, 94, 96, 98, 683, 13, + 100, 17, 102, 104, 106, 65, 108, 110, 257, 112, 114, 1153, 19, 116, 118, 120, 122, 124, 49, 126, 128, + 769, 289, 130, 132, 134, 73, 136, 138, 140, 142, 193, 144, 146, 148, 150, 152, 154, 517, 156, 158, 37, + 51, 160, 201, 162, 145, 164, 166, 168, 133, 170, 801, 45, 172, 174, 1057, 176, 178, 67, 180, 1027, 577, + 182, 184, 186, 188, 190, 192, 194, 196, 198, 259, 200, 202, 204, 525, 177, 265, 141, 206, 208, 210, 212, + 195, 297, 214, 75, 216, 1033, 203, 585, 1155, 1185, 267, 1161, 549, 218, 220, 657, 777, 147, 222, 224, 226, + 228, 230, 232, 234, 236, 238, 240, 587, 645, 165, 242, 244, 246, 248, 250, 771, 291, 252, 579, 1065, 1035, + 705, 531, 529, 659, 173, 254, 561, 653, 256, 713, 677, 557, 258, 260, 262, 264, 266, 268, 270, 272, 274, + 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 707, 1059, 809, 715, 563, 179, 691, 1193, + 21, 779, 1067, 299, 1187, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, + 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, + 376, 378, 380, 83, 69, 1281, 803, 321, 1195, 1163, 811, 1323, 689, 1321, 1099, 305, 835, 1227, 331, 843, 785, + 593, 1043, 1291, 1283, 1171, 275, 787, 1217, 833, 1075, 1313, 1219, 1203, 307, 819, 841, 595, 211, 723, 721, 817, + 1029, 329, 81, 1157, 261, 773, 1097, 1089, 1061, 1169, 1091, 1189, 293, 805, 1201, 581, 197, 709, 1289, 273, 1037, + 1315, 1041, 1165, 269, 781, 209, 1073, 1069, 323, 685, 1197, 301, 813, 77, 589, 205, 717, 1225, 533, 149, 661, + 53, 565, 181, 693, 0, 0}; + + +static const int decoder_tree6[62] = { + 2, 1, 4, 6, 8, 10, 12, 14, 16, 3, + 33, 5, 17, 9, 18, 20, 22, 24, 26, 28, + 30, 32, 34, 7, 49, 13, 25, 36, 38, 11, + 21, 41, 35, 37, 19, 40, 42, 44, 46, 48, + 50, 15, 52, 57, 29, 27, 23, 53, 54, 51, + 39, 45, 43, 56, 58, 31, 55, 60, 61, 47, + 59, 63}; + +static const int *decoder_tables[7] = { + decoder_tree0, + decoder_tree1, + decoder_tree2, + decoder_tree3, + decoder_tree4, + decoder_tree5, + decoder_tree6, +}; + +static const float noise_category5[20] = {0.70711f, 0.6179f, 0.5005f, 0.3220f, + 0.17678f, 0.17678f, 0.17678f, 0.17678f, + 0.17678f, 0.17678f, 0.17678f, 0.17678f, + 0.17678f, 0.17678f, 0.17678f, 0.17678f, + 0.17678f, 0.17678f, 0.17678f, 0.17678f}; + +static const float noise_category6[20] = {0.70711f, 0.5686f, 0.3563f, 0.25f, + 0.25f, 0.25f, 0.25f, 0.25f, + 0.25f, 0.25f, 0.25f, 0.25f, + 0.25f, 0.25f, 0.25f, 0.25f, + 0.25f, 0.25f, 0.25f, 0.25f}; + +static const float noise_category7 = 0.70711f; + + +static const int index_table[8] = {4, 4, 3, 3, 2, 2, 1, 0}; + +#endif /* _HUFFMAN_CONSTS_H */ diff --git a/Frameworks/g7221/g7221/libsiren/rmlt.c b/Frameworks/g7221/g7221/libsiren/rmlt.c new file mode 100644 index 000000000..df3088c9e --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/rmlt.c @@ -0,0 +1,149 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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 "siren7.h" + + +static int rmlt_initialized = 0; +static float rmlt_window_640[640]; +static float rmlt_window_320[320]; + +#define PI_2 1.57079632679489661923 + +void +siren_rmlt_init (void) +{ + int i = 0; + float angle; + + for (i = 0; i < 640; i++) { + angle = (float) (((i + 0.5) * PI_2) / 640); + rmlt_window_640[i] = (float) sin (angle); + } + for (i = 0; i < 320; i++) { + angle = (float) (((i + 0.5) * PI_2) / 320); + rmlt_window_320[i] = (float) sin (angle); + } + + rmlt_initialized = 1; +} + +int +siren_rmlt_encode_samples (float *samples, float *old_samples, int dct_length, + float *rmlt_coefs) +{ + int half_dct_length = dct_length / 2; + float *old_ptr = old_samples + half_dct_length; + float *coef_high = rmlt_coefs + half_dct_length; + float *coef_low = rmlt_coefs + half_dct_length; + float *samples_low = samples; + float *samples_high = samples + dct_length; + float *window_low = NULL; + float *window_high = NULL; + int i = 0; + + if (rmlt_initialized == 0) + siren_rmlt_init (); + + if (dct_length == 320) + window_low = rmlt_window_320; + else if (dct_length == 640) + window_low = rmlt_window_640; + else + return 4; + + window_high = window_low + dct_length; + + + for (i = 0; i < half_dct_length; i++) { + *--coef_low = *--old_ptr; + *coef_high++ = + (*samples_low * *--window_high) - (*--samples_high * *window_low); + *old_ptr = + (*samples_high * *window_high) + (*samples_low++ * *window_low++); + } + siren_dct4 (rmlt_coefs, rmlt_coefs, dct_length); + + return 0; +} + + + +int +siren_rmlt_decode_samples (float *coefs, float *old_coefs, int dct_length, + float *samples) +{ + int half_dct_length = dct_length / 2; + float *old_low = old_coefs; + float *old_high = old_coefs + half_dct_length; + float *samples_low = samples; + float *samples_high = samples + dct_length; + float *samples_middle_low = samples + half_dct_length; + float *samples_middle_high = samples + half_dct_length; + float *window_low = NULL; + float *window_high = NULL; + float *window_middle_low = NULL; + float *window_middle_high = NULL; + float sample_low_val; + float sample_high_val; + float sample_middle_low_val; + float sample_middle_high_val; + int i = 0; + + if (rmlt_initialized == 0) + siren_rmlt_init (); + + if (dct_length == 320) + window_low = rmlt_window_320; + else if (dct_length == 640) + window_low = rmlt_window_640; + else + return 4; + + + window_high = window_low + dct_length; + window_middle_low = window_low + half_dct_length; + window_middle_high = window_low + half_dct_length; + + siren_dct4 (coefs, samples, dct_length); + + for (i = 0; i < half_dct_length; i += 2) { + sample_low_val = *samples_low; + sample_high_val = *--samples_high; + sample_middle_low_val = *--samples_middle_low; + sample_middle_high_val = *samples_middle_high; + *samples_low++ = + (*old_low * *--window_high) + (sample_middle_low_val * *window_low); + *samples_high = + (sample_middle_low_val * *window_high) - (*old_low * *window_low++); + *samples_middle_high++ = + (sample_low_val * *window_middle_high) - + (*--old_high * *--window_middle_low); + *samples_middle_low = + (*old_high * *window_middle_high++) + + (sample_low_val * *window_middle_low); + *old_low++ = sample_middle_high_val; + *old_high = sample_high_val; + } + + return 0; +} diff --git a/Frameworks/g7221/g7221/libsiren/rmlt.h b/Frameworks/g7221/g7221/libsiren/rmlt.h new file mode 100644 index 000000000..27257cf1d --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/rmlt.h @@ -0,0 +1,30 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + + +#ifndef _SIREN7_RMLT_H_ +#define _SIREN7_RMLT_H_ + +extern void siren_rmlt_init(void); +extern int siren_rmlt_encode_samples(float *samples, float *old_samples, int dct_length, float *rmlt_coefs); +extern int siren_rmlt_decode_samples(float *coefs, float *old_coefs, int dct_length, float *samples); + +#endif /* _SIREN7_RMLT_H_ */ diff --git a/Frameworks/g7221/g7221/libsiren/siren7.h b/Frameworks/g7221/g7221/libsiren/siren7.h new file mode 100644 index 000000000..5348028be --- /dev/null +++ b/Frameworks/g7221/g7221/libsiren/siren7.h @@ -0,0 +1,36 @@ +/* + * Siren Encoder/Decoder library + * + * @author: Youness Alaoui + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + */ + + +#ifndef _SIREN7_H +#define _SIREN7_H + +// Configuration: +#define __BIG_ENDIAN_FRAMES__ // bitstream words are in big endian order already +//#define __BIG_ENDIAN__ // sample data should be big endian +//#define __WAV_HEADER__ // encoder and decoder maintain RIFF WAV header for caller +#define __NO_CONTROL_OR_CHECK_FIELDS__ // sample rate control and checksum fields are not encoded or decoded + +#include "encoder.h" +#include "decoder.h" + + +#endif /* _SIREN7_H */ diff --git a/Frameworks/vgmstream/vgmstream.xcodeproj/project.pbxproj b/Frameworks/vgmstream/vgmstream.xcodeproj/project.pbxproj index 61c902358..85fafcbef 100644 --- a/Frameworks/vgmstream/vgmstream.xcodeproj/project.pbxproj +++ b/Frameworks/vgmstream/vgmstream.xcodeproj/project.pbxproj @@ -326,6 +326,11 @@ 836F705918BDC2190095E648 /* vgmstream.h in Headers */ = {isa = PBXBuildFile; fileRef = 836F6F1D18BDC2190095E648 /* vgmstream.h */; settings = {ATTRIBUTES = (Public, ); }; }; 83A5F75F198DF021009AF94C /* bfwav.c in Sources */ = {isa = PBXBuildFile; fileRef = 83A5F75E198DF021009AF94C /* bfwav.c */; }; 83BAFB6C19F45EB3005DAB60 /* bfstm.c in Sources */ = {isa = PBXBuildFile; fileRef = 83BAFB6B19F45EB3005DAB60 /* bfstm.c */; }; + 83D731101A7394BF00CA1366 /* g7221.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83D730EB1A738EB300CA1366 /* g7221.framework */; }; + 83D731111A7394D300CA1366 /* g7221.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83D730EB1A738EB300CA1366 /* g7221.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 83D731891A749D1500CA1366 /* g719.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83D7313E1A74968A00CA1366 /* g719.framework */; }; + 83D7318A1A749D2200CA1366 /* g719.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 83D7313E1A74968A00CA1366 /* g719.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 83D7318C1A749EEE00CA1366 /* g719_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 83D7318B1A749EEE00CA1366 /* g719_decoder.c */; }; 83EDE5D81A70951A005F5D84 /* mca.c in Sources */ = {isa = PBXBuildFile; fileRef = 83EDE5D61A70951A005F5D84 /* mca.c */; }; 83EDE5D91A70951A005F5D84 /* btsnd.c in Sources */ = {isa = PBXBuildFile; fileRef = 83EDE5D71A70951A005F5D84 /* btsnd.c */; }; 83F5F8831908D0A400C8E65F /* fsb5.c in Sources */ = {isa = PBXBuildFile; fileRef = 83F5F8821908D0A400C8E65F /* fsb5.c */; }; @@ -393,6 +398,34 @@ remoteGlobalIDString = 8313E30E1901FBDC00B4B6F1; remoteInfo = mpg123; }; + 83D730EA1A738EB300CA1366 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 83D730E51A738EB200CA1366 /* g7221.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 83D730C91A738EB200CA1366; + remoteInfo = g7221; + }; + 83D7310E1A7394B500CA1366 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 83D730E51A738EB200CA1366 /* g7221.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 83D730C81A738EB200CA1366; + remoteInfo = g7221; + }; + 83D7313D1A74968A00CA1366 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 83D731381A74968900CA1366 /* g719.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 83D7311C1A74968900CA1366; + remoteInfo = g719; + }; + 83D731871A749D0D00CA1366 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 83D731381A74968900CA1366 /* g719.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 83D7311B1A74968900CA1366; + remoteInfo = g719; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -402,6 +435,8 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + 83D7318A1A749D2200CA1366 /* g719.framework in CopyFiles */, + 83D731111A7394D300CA1366 /* g7221.framework in CopyFiles */, 830F884019C9102F00420FB0 /* Vorbis.framework in CopyFiles */, 8313E3E71902021800B4B6F1 /* mpg123.framework in CopyFiles */, ); @@ -729,6 +764,9 @@ 836F6F1D18BDC2190095E648 /* vgmstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vgmstream.h; sourceTree = ""; }; 83A5F75E198DF021009AF94C /* bfwav.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bfwav.c; sourceTree = ""; }; 83BAFB6B19F45EB3005DAB60 /* bfstm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bfstm.c; sourceTree = ""; }; + 83D730E51A738EB200CA1366 /* g7221.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = g7221.xcodeproj; path = ../g7221/g7221.xcodeproj; sourceTree = ""; }; + 83D731381A74968900CA1366 /* g719.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = g719.xcodeproj; path = ../g719/g719.xcodeproj; sourceTree = ""; }; + 83D7318B1A749EEE00CA1366 /* g719_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g719_decoder.c; sourceTree = ""; }; 83EDE5D61A70951A005F5D84 /* mca.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mca.c; sourceTree = ""; }; 83EDE5D71A70951A005F5D84 /* btsnd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = btsnd.c; sourceTree = ""; }; 83F5F8821908D0A400C8E65F /* fsb5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fsb5.c; sourceTree = ""; }; @@ -739,6 +777,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 83D731891A749D1500CA1366 /* g719.framework in Frameworks */, + 83D731101A7394BF00CA1366 /* g7221.framework in Frameworks */, 8313E3E61902020400B4B6F1 /* mpg123.framework in Frameworks */, 830F885C19C9124C00420FB0 /* Vorbis.framework in Frameworks */, ); @@ -797,6 +837,8 @@ children = ( 8315231718BDECA1009AE289 /* VorbisNoDot.xcodeproj */, 8313E33D1901FBDC00B4B6F1 /* mpg123.xcodeproj */, + 83D730E51A738EB200CA1366 /* g7221.xcodeproj */, + 83D731381A74968900CA1366 /* g719.xcodeproj */, ); name = "Other Frameworks"; sourceTree = ""; @@ -839,6 +881,7 @@ 836F6DDF18BDC2180095E648 /* coding */ = { isa = PBXGroup; children = ( + 83D7318B1A749EEE00CA1366 /* g719_decoder.c */, 836F6DE018BDC2180095E648 /* acm_decoder.c */, 836F6DE118BDC2180095E648 /* acm_decoder.h */, 836F6DE218BDC2180095E648 /* adx_decoder.c */, @@ -1166,6 +1209,22 @@ path = meta; sourceTree = ""; }; + 83D730E61A738EB200CA1366 /* Products */ = { + isa = PBXGroup; + children = ( + 83D730EB1A738EB300CA1366 /* g7221.framework */, + ); + name = Products; + sourceTree = ""; + }; + 83D731391A74968900CA1366 /* Products */ = { + isa = PBXGroup; + children = ( + 83D7313E1A74968A00CA1366 /* g719.framework */, + ); + name = Products; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -1204,6 +1263,8 @@ 48C265101A5D424500A0A3D6 /* PBXBuildRule */, ); dependencies = ( + 83D731881A749D0D00CA1366 /* PBXTargetDependency */, + 83D7310F1A7394B500CA1366 /* PBXTargetDependency */, 830F883319C9101900420FB0 /* PBXTargetDependency */, 8313E3E91902021F00B4B6F1 /* PBXTargetDependency */, ); @@ -1232,6 +1293,14 @@ productRefGroup = 836F6B3A18BDB8880095E648 /* Products */; projectDirPath = ""; projectReferences = ( + { + ProductGroup = 83D731391A74968900CA1366 /* Products */; + ProjectRef = 83D731381A74968900CA1366 /* g719.xcodeproj */; + }, + { + ProductGroup = 83D730E61A738EB200CA1366 /* Products */; + ProjectRef = 83D730E51A738EB200CA1366 /* g7221.xcodeproj */; + }, { ProductGroup = 8313E33E1901FBDC00B4B6F1 /* Products */; ProjectRef = 8313E33D1901FBDC00B4B6F1 /* mpg123.xcodeproj */; @@ -1284,6 +1353,20 @@ remoteRef = 8313E3421901FBDD00B4B6F1 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + 83D730EB1A738EB300CA1366 /* g7221.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = g7221.framework; + remoteRef = 83D730EA1A738EB300CA1366 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 83D7313E1A74968A00CA1366 /* g719.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = g719.framework; + remoteRef = 83D7313D1A74968A00CA1366 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -1381,6 +1464,7 @@ 836F6F6C18BDC2190095E648 /* ahx.c in Sources */, 836F702D18BDC2190095E648 /* sfl.c in Sources */, 836F6FEC18BDC2190095E648 /* ps2_mtaf.c in Sources */, + 83D7318C1A749EEE00CA1366 /* g719_decoder.c in Sources */, 836F701118BDC2190095E648 /* ps3_cps.c in Sources */, 836F701418BDC2190095E648 /* ps3_msf.c in Sources */, 836F6F6518BDC2190095E648 /* 2dx9.c in Sources */, @@ -1624,6 +1708,16 @@ name = mpg123; targetProxy = 8313E3E81902021F00B4B6F1 /* PBXContainerItemProxy */; }; + 83D7310F1A7394B500CA1366 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = g7221; + targetProxy = 83D7310E1A7394B500CA1366 /* PBXContainerItemProxy */; + }; + 83D731881A749D0D00CA1366 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = g719; + targetProxy = 83D731871A749D0D00CA1366 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ diff --git a/Frameworks/vgmstream/vgmstream/src/coding/coding.h b/Frameworks/vgmstream/vgmstream/src/coding/coding.h index dfaad0efa..1502d57ea 100644 --- a/Frameworks/vgmstream/vgmstream/src/coding/coding.h +++ b/Frameworks/vgmstream/vgmstream/src/coding/coding.h @@ -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/Frameworks/vgmstream/vgmstream/src/coding/g719_decoder.c b/Frameworks/vgmstream/vgmstream/src/coding/g719_decoder.c new file mode 100644 index 000000000..67a98aed1 --- /dev/null +++ b/Frameworks/vgmstream/vgmstream/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/Frameworks/vgmstream/vgmstream/src/coding/g7221_decoder.c b/Frameworks/vgmstream/vgmstream/src/coding/g7221_decoder.c index a55e4602e..6ca80b038 100644 --- a/Frameworks/vgmstream/vgmstream/src/coding/g7221_decoder.c +++ b/Frameworks/vgmstream/vgmstream/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/Frameworks/vgmstream/vgmstream/src/meta/bnsf.c b/Frameworks/vgmstream/vgmstream/src/meta/bnsf.c index de9a59eca..91c020b00 100644 --- a/Frameworks/vgmstream/vgmstream/src/meta/bnsf.c +++ b/Frameworks/vgmstream/vgmstream/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/Frameworks/vgmstream/vgmstream/src/meta/ngc_dsp_std.c b/Frameworks/vgmstream/vgmstream/src/meta/ngc_dsp_std.c index 7e8097c1b..5693e0bef 100644 --- a/Frameworks/vgmstream/vgmstream/src/meta/ngc_dsp_std.c +++ b/Frameworks/vgmstream/vgmstream/src/meta/ngc_dsp_std.c @@ -2379,7 +2379,7 @@ VGMSTREAM * init_vgmstream_dsp_dspw(STREAMFILE *streamFile) { VARDECL(struct dsp_header, ch_header); VARDECL(off_t, channel_start); - channel_count = read_8bit(0x1B, streamFile); + channel_count = (unsigned char)read_8bit(0x1B, streamFile); ALLOC(ch_header, channel_count, struct dsp_header); ALLOC(channel_start, channel_count, off_t); diff --git a/Frameworks/vgmstream/vgmstream/src/vgmstream.c b/Frameworks/vgmstream/vgmstream/src/vgmstream.c index 8bfea8490..c33b9cb94 100644 --- a/Frameworks/vgmstream/vgmstream/src/vgmstream.c +++ b/Frameworks/vgmstream/vgmstream/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/Frameworks/vgmstream/vgmstream/src/vgmstream.h b/Frameworks/vgmstream/vgmstream/src/vgmstream.h index 00387d82a..20976d9ad 100644 --- a/Frameworks/vgmstream/vgmstream/src/vgmstream.h +++ b/Frameworks/vgmstream/vgmstream/src/vgmstream.h @@ -15,7 +15,8 @@ enum { PATH_LIMIT = 32768 }; #define VGM_USE_VORBIS #define VGM_USE_MPEG /* disabled by default, defined for builds that support it */ -//#define VGM_USE_G7221 +#define VGM_USE_G7221 +#define VGM_USE_G719 #include "streamfile.h" #ifdef BUILD_VGMSTREAM @@ -33,7 +34,10 @@ enum { PATH_LIMIT = 32768 }; #include #endif #ifdef VGM_USE_G7221 -#include "g7221.h" +#include +#endif +#ifdef VGM_USE_G719 +#include #endif #ifdef VGM_USE_MP4V2 @@ -137,6 +141,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 */ @@ -752,6 +759,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;