Updated vgmstream with support for G.722.1 and G.719 codecs

CQTexperiment
Chris Moeller 2015-01-24 21:22:21 -08:00
parent 8f1d76bd92
commit faae95ddcb
60 changed files with 10127 additions and 5 deletions

View File

@ -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 = "<group>"; };
83D731411A749C5D00CA1366 /* g719.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g719.c; sourceTree = "<group>"; };
83D731441A749C5D00CA1366 /* bitalloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bitalloc.c; sourceTree = "<group>"; };
83D731451A749C5D00CA1366 /* bitstream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bitstream.c; sourceTree = "<group>"; };
83D731461A749C5D00CA1366 /* codesearch.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = codesearch.c; sourceTree = "<group>"; };
83D731471A749C5D00CA1366 /* common_rom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = common_rom.c; sourceTree = "<group>"; };
83D731481A749C5D00CA1366 /* complxop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = complxop.c; sourceTree = "<group>"; };
83D7314A1A749C5D00CA1366 /* dct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dct.c; sourceTree = "<group>"; };
83D7314B1A749C5D00CA1366 /* idx2code.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = idx2code.c; sourceTree = "<group>"; };
83D7314C1A749C5D00CA1366 /* interleave_spectrum.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = interleave_spectrum.c; sourceTree = "<group>"; };
83D7314D1A749C5D00CA1366 /* recovernorm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = recovernorm.c; sourceTree = "<group>"; };
83D7314E1A749C5D00CA1366 /* reordvct.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = reordvct.c; sourceTree = "<group>"; };
83D7314F1A749C5D00CA1366 /* weight.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = weight.c; sourceTree = "<group>"; };
83D731511A749C5D00CA1366 /* decode_frame.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = decode_frame.c; sourceTree = "<group>"; };
83D731531A749C5D00CA1366 /* decoder_init.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = decoder_init.c; sourceTree = "<group>"; };
83D731541A749C5D00CA1366 /* decoder_rom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = decoder_rom.c; sourceTree = "<group>"; };
83D731551A749C5D00CA1366 /* dprocnf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dprocnf.c; sourceTree = "<group>"; };
83D731561A749C5D00CA1366 /* dprocnobitsbfm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dprocnobitsbfm.c; sourceTree = "<group>"; };
83D731571A749C5D00CA1366 /* dqcoefs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dqcoefs.c; sourceTree = "<group>"; };
83D731581A749C5D00CA1366 /* fill_spectrum.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fill_spectrum.c; sourceTree = "<group>"; };
83D731591A749C5D00CA1366 /* flvqdec.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = flvqdec.c; sourceTree = "<group>"; };
83D7315A1A749C5D00CA1366 /* hdeclvq.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hdeclvq.c; sourceTree = "<group>"; };
83D7315B1A749C5D00CA1366 /* hdecnrm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hdecnrm.c; sourceTree = "<group>"; };
83D7315C1A749C5D00CA1366 /* trans_inv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = trans_inv.c; sourceTree = "<group>"; };
83D7315D1A749C5D00CA1366 /* unpackc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = unpackc.c; sourceTree = "<group>"; };
83D7315E1A749C5D00CA1366 /* window_ola.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = window_ola.c; sourceTree = "<group>"; };
83D731601A749C5D00CA1366 /* cnst.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cnst.h; sourceTree = "<group>"; };
83D731611A749C5D00CA1366 /* complxop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = complxop.h; sourceTree = "<group>"; };
83D731621A749C5D00CA1366 /* proto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = proto.h; sourceTree = "<group>"; };
83D731631A749C5D00CA1366 /* rom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rom.h; sourceTree = "<group>"; };
83D731641A749C5D00CA1366 /* state.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = state.h; sourceTree = "<group>"; };
83D731851A749C7800CA1366 /* g719.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = g719.h; sourceTree = "<group>"; };
83D7318D1A74A54000CA1366 /* stack_alloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stack_alloc.h; sourceTree = "<group>"; };
/* 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 = "<group>";
};
83D7311D1A74968900CA1366 /* Products */ = {
isa = PBXGroup;
children = (
83D7311C1A74968900CA1366 /* g719.framework */,
);
name = Products;
sourceTree = "<group>";
};
83D7311E1A74968900CA1366 /* g719 */ = {
isa = PBXGroup;
children = (
83D7318D1A74A54000CA1366 /* stack_alloc.h */,
83D731851A749C7800CA1366 /* g719.h */,
83D731411A749C5D00CA1366 /* g719.c */,
83D731421A749C5D00CA1366 /* reference_code */,
83D7311F1A74968900CA1366 /* Supporting Files */,
);
path = g719;
sourceTree = "<group>";
};
83D7311F1A74968900CA1366 /* Supporting Files */ = {
isa = PBXGroup;
children = (
83D731201A74968900CA1366 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
83D731421A749C5D00CA1366 /* reference_code */ = {
isa = PBXGroup;
children = (
83D731431A749C5D00CA1366 /* common */,
83D731501A749C5D00CA1366 /* decoder */,
83D7315F1A749C5D00CA1366 /* include */,
);
path = reference_code;
sourceTree = "<group>";
};
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 = "<group>";
};
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 = "<group>";
};
83D7315F1A749C5D00CA1366 /* include */ = {
isa = PBXGroup;
children = (
83D731601A749C5D00CA1366 /* cnst.h */,
83D731611A749C5D00CA1366 /* complxop.h */,
83D731621A749C5D00CA1366 /* proto.h */,
83D731631A749C5D00CA1366 /* rom.h */,
83D731641A749C5D00CA1366 /* state.h */,
);
path = include;
sourceTree = "<group>";
};
/* 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 */;
}

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.cogx.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Christopher Snowhill. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -0,0 +1,54 @@
//
// g719.c
// g719
//
// Created by Christopher Snowhill on 1/24/15.
// Copyright (c) 2015 Christopher Snowhill. All rights reserved.
//
#include <stdlib.h>
#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);
}

23
Frameworks/g719/g719/g719.h Executable file
View File

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

View File

@ -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<n; i++)
{
k = 0;
temp = y[0];
for (m=1; m<=im; m++)
{
if (temp<y[m])
{
temp = y[m];
k = m;
}
}
if (k==im)
{
im++;
}
j = idx[k];
if ((sum>=sfmsize[j]) && (r[j]<M))
{
y[k] -= 2;
r[j]++;
if (r[j]>=M)
{
y[k] = MIN16B;
}
sum -= sfmsize[j];
}
else
{
y[k] = MIN16B;
k++;
if (k==im)
{
im++;
}
}
if ((sum<WID_G1) || (diff==sum))
{
break;
}
diff = sum;
v = N - 2;
if (k>v)
{
for (i=0; i<N; i++)
{
if (y[i]>MIN16B)
{
im = i + 1;
break;
}
}
}
}
if (sum>=WID_G2)
{
for (i=0; i<N; i++)
{
j = idx[i];
if ((j>=SFM_G1) && (j<SFM_G1G2) && (r[j]==0))
{
r[j] = 1;
sum -= WID_G2;
if (sum<WID_G2)
{
break;
}
}
}
}
if (sum>=WID_G2)
{
for (i=0; i<N; i++)
{
j = idx[i];
if ((j>=SFM_G1) && (j<SFM_G1G2) && (r[j]==1))
{
r[j] = 2;
sum -= WID_G2;
if (sum<WID_G2)
{
break;
}
}
}
}
if (sum>=WID_G1)
{
for (i=0; i<N; i++)
{
j = idx[i];
if ((j<SFM_G1) && (r[j]==0))
{
r[j] = 1;
sum -= WID_G1;
if (sum<WID_G1)
{
break;
}
}
}
}
if (sum>=WID_G1)
{
for (i=0; i<N; i++)
{
j = idx[i];
if ((j<SFM_G1) && (r[j]==1))
{
r[j] = 2;
sum -= WID_G1;
if (sum<WID_G1)
{
break;
}
}
}
}
return;
}

View File

@ -0,0 +1,159 @@
/*--------------------------------------------------------------------------*/
/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */
/* © 2008 Ericsson AB. and Polycom Inc. */
/* All rights reserved. */
/*--------------------------------------------------------------------------*/
#include "cnst.h"
/*--------------------------------------------------------------------------*/
/* Function idx2bitsn */
/* ~~~~~~~~~~~~~~~~~~~ */
/* */
/* Conversion from norm index into ITU bit stream */
/*--------------------------------------------------------------------------*/
/* short x (i) index of quantized norm */
/* short N (i) bits per norm */
/* short *y (o) ITU bitstream */
/*--------------------------------------------------------------------------*/
void idx2bitsn(short x, short N, short *y)
{
short i;
short temp;
y += N;
for (i=0; i<N; i++)
{
temp = (x >> 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<n; j++)
{
y += m;
pty = y;
for (i=0; i<m; i++)
{
temp = (x[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<N; i++)
{
*x <<= 1;
if ((*y++)==G192_BIT1)
{
*x += 1;
}
}
return;
}
/*--------------------------------------------------------------------------*/
/* Function bits2idxc */
/* ~~~~~~~~~~~~~~~~~~~ */
/* */
/* Conversion from ITU bit stream into coefficient index */
/*--------------------------------------------------------------------------*/
/* short *y (i) ITU bitstream */
/* short N (i) vector dimensions */
/* short L (i) bits per coefficient */
/* short *x (o) index of quantized coefficient */
/*--------------------------------------------------------------------------*/
void bits2idxc(short *y, short N, short L, short *x)
{
short i, k, m, n;
short temp;
if (L==1)
{
n = 1;
m = N;
}
else
{
n = N;
m = L;
}
for (k=0; k<n; k++)
{
x[k] = 0;
for (i=0; i<m; i++)
{
temp = x[k] << 1;
if ((*y++)==G192_BIT1)
{
temp += 1;
}
x[k] = temp;
}
}
return;
}

View File

@ -0,0 +1,66 @@
/*--------------------------------------------------------------------------*/
/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */
/* © 2008 Ericsson AB. and Polycom Inc. */
/* All rights reserved. */
/*--------------------------------------------------------------------------*/
#include "rom.h"
/*--------------------------------------------------------------------------*/
/* Function codesearch */
/* ~~~~~~~~~~~~~~~~~~~~ */
/* */
/* Finding the closest point of lattice */
/*--------------------------------------------------------------------------*/
/* float *x (i) arbitrary vector in Qv */
/* short *C (o) point of lattice */
/* Word16 R (i) number of bits per coefficient */
/*--------------------------------------------------------------------------*/
void codesearch(short *x, short *C, short R)
{
short i, j, sum;
short e[8], em, temp;
sum = 0;
for (i=0; i<8; i++)
{
temp = x[i] & FacLVQ2Mask[R];
C[i] = x[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<temp)
{
em = temp;
j = i;
}
}
if (e[j]>=0)
{
C[j] += 1;
}
else
{
C[j] -= 1;
}
}
return;
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -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<STOP_BAND; i+=STOP_BAND4)
{
pcoefs = coefs_short + i;
pcoefs1 = coefs_short + 16 + i;
for (j=0; j<16; j++)
{
*pcoefs++ = *p1a++;
*pcoefs1++ = *p1b++;
}
pcoefs = coefs_short + NUMC_G1SUB + i;
pcoefs1 = coefs_short + NUMC_G1SUB + 16 + i;
for (j=0; j<16; j++)
{
*pcoefs++ = *p2a++;
*pcoefs1++ = *p2b++;
}
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++)
{
*pcoefs++ = *p3a++;
*pcoefs1++ = *p3b++;
*pcoefs2++ = *p3c++;
}
pcoefs = coefs_short + NUMC_G1G2G3SUB + i;
pcoefs1 = coefs_short + NUMC_G1G2G3SUB + WID_GX + i;
for (j=0; j<WID_GX; j++)
{
*pcoefs++ = *p4a++;
*pcoefs1++ = *p4b++;
}
}
/* unpack the spectrum */
p1a = coefs_short;
pcoefs = coefs;
for (i=0; i<4; i++)
{
for (j=0; j<STOP_BAND4; j++)
{
pcoefs[j] = p1a[j];
}
for (j=STOP_BAND4; j<FRAME_LENGTH/4; j++)
{
pcoefs[j] = 0;
}
p1a += STOP_BAND4;
pcoefs += FRAME_LENGTH/4;
}
}

View File

@ -0,0 +1,81 @@
/*--------------------------------------------------------------------------*/
/* 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 recovernorm */
/* ~~~~~~~~~~~~~~~~~~~~~ */
/* */
/* Recover reordered quantization indices and norms */
/*--------------------------------------------------------------------------*/
/* short *idxbuf (i) reordered quantization indices */
/* short *ynrm (o) recovered quantization indices */
/* short *normqlg2 (o) recovered quantized norms */
/*--------------------------------------------------------------------------*/
void recovernorm(
short *idxbuf,
short *ynrm,
short *normqlg2
)
{
short i;
short *pidx, *pnormq;
for (i=0; i<2; i++)
{
pidx = ynrm + i;
pnormq = normqlg2 + i;
*pidx = idxbuf[i];
*pnormq = dicnlg2[*pidx];
pidx += 2;
pnormq += 2;
*pidx = idxbuf[21-i];
*pnormq = dicnlg2[*pidx];
pidx += 2;
pnormq += 2;
*pidx = idxbuf[22+i];
*pnormq = dicnlg2[*pidx];
pidx += 2;
pnormq += 2;
*pidx = idxbuf[43-i];
*pnormq = dicnlg2[*pidx];
pidx += 2;
pnormq += 2;
*pidx = idxbuf[i+2];
*pnormq = dicnlg2[*pidx];
pidx += 2;
pnormq += 2;
*pidx = idxbuf[19-i];
*pnormq = dicnlg2[*pidx];
pidx += 2;
pnormq += 2;
*pidx = idxbuf[24+i];
*pnormq = dicnlg2[*pidx];
pidx += 2;
pnormq += 2;
*pidx = idxbuf[41-i];
*pnormq = dicnlg2[*pidx];
}
pidx = ynrm + 16;
pnormq = normqlg2 + 16;
for (i=4; i<(NB_SFM/4); i++)
{
*pidx = idxbuf[i];
*pnormq++ = dicnlg2[*pidx++];
*pidx = idxbuf[21-i];
*pnormq++ = dicnlg2[*pidx++];
*pidx = idxbuf[22+i];
*pnormq++ = dicnlg2[*pidx++];
*pidx = idxbuf[43-i];
*pnormq++ = dicnlg2[*pidx++];
}
return;
}

View File

@ -0,0 +1,43 @@
/*--------------------------------------------------------------------------*/
/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */
/* © 2008 Ericsson AB. and Polycom Inc. */
/* All rights reserved. */
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
/* Function reordvct */
/* ~~~~~~~~~~~~~~~~~~ */
/* */
/* Rearrange a vector in decreasing order */
/*--------------------------------------------------------------------------*/
/* short *y (i/o) vector to rearrange */
/* short N (i) dimensions */
/* short *idx (o) reordered vector index */
/*--------------------------------------------------------------------------*/
void reordvct(short *y, short N, short *idx)
{
short i, j, k, n, im, temp;
n = N - 1;
for (i=0; i<n; i++)
{
im = i;
k = i + 1;
for (j=k; j<N; j++)
{
temp = y[im] - y[j];
if (temp<0)
{
im = j;
}
}
temp = y[i];
y[i] = y[im];
y[im] = temp;
j = idx[i];
idx[i] = idx[im];
idx[im] = j;
}
return;
}

View File

@ -0,0 +1,302 @@
/*--------------------------------------------------------------------------*/
/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */
/* © 2008 Ericsson AB. and Polycom Inc. */
/* All rights reserved. */
/*--------------------------------------------------------------------------*/
#include "cnst.h"
#include <math.h>
/*--------------------------------------------------------------------------*/
/* 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]<tmp16)
{
spe2q[sfm] = tmp16;
}
}
for (sfm = NUM_MAP_BANDS-2 ; sfm >= 0 ; sfm--)
{
tmp16 = spe2q[sfm+1] - 8;
if (spe2q[sfm]<tmp16)
{
spe2q[sfm] = tmp16;
}
}
for (sfm = 0; sfm < NUM_MAP_BANDS ; sfm++)
{
if (spe2q[sfm]<a[sfm])
{
spe2q[sfm] = a[sfm];
}
}
/* Saturate by the Absolute Threshold of Hearing */
spe2q_max = MIN16B;
spe2q_min = MAX16B;
for (sfm = 0; sfm < NUM_MAP_BANDS ; sfm++)
{
spe2q[sfm] = sfm_width[sfm] - spe2q[sfm];
if (spe2q_max<spe2q[sfm])
{
spe2q_max = spe2q[sfm];
}
if (spe2q_min>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];
}
}

View File

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

View File

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

View File

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

View File

@ -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; i<nb_vecs; i++)
{
bits2idxc(pbits, 8, 1, y);
pbits += 8;
if ((pre_idx<128) && (*y<16))
{
for (j=0; j<8; j++)
{
*coefs_norm = OFFSETf;
*coefs++ = (*coefs_norm++) * normq;
}
}
else
{
for (j=0; j<8; j++)
{
*coefs_norm = (float)dic4[*y][j] / FCT_LVQ1f + OFFSETf;
*coefs++ = (*coefs_norm++) * normq;
}
}
pre_idx = *y;
y += 8;
}
return;
}

View File

@ -0,0 +1,106 @@
/*--------------------------------------------------------------------------*/
/* 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"
/*--------------------------------------------------------------------------*/
/* Function dprocnobitsbfm */
/* ~~~~~~~~~~~~~~~~~~~~~~~~ */
/* */
/* Decoding for sub-vectors originally allocated with 0 bits */
/*--------------------------------------------------------------------------*/
/* short *R (i/o) number of bits per coefficinet */
/* short *idx (i) reordered sub-vector indices */
/* short *ynrm (i) quantization indices for norms */
/* short *ycof (i) quantization indices for MLT coefficients */
/* short **ppbits (i/o) pointer to bitstream */
/* float *coefsq (o) reconstructed MLT coefficients */
/* float *coefsq_norm (o) reconstructed normalized MLT coefficients */
/* short nb_sfm (i) number of sub-vectors to be coded */
/* short diff (i) number of available bits */
/*--------------------------------------------------------------------------*/
void dprocnobitsbfm(
short *R,
short *idx,
short *ynrm,
short *ycof,
short **ppbits,
float *coefsq,
float *coefsq_norm,
short nb_sfm,
short diff
)
{
short i, k, m, im, offset;
short *pbits;
pbits = *ppbits;
im = MAX16B;
k = nb_sfm - 1;
for (i=k; i>0; i--)
{
if (R[idx[i]]==0)
{
im = i;
}
}
for (i=im; i<nb_sfm; i++)
{
m = idx[i];
if (R[m]==0)
{
if (m<SFM_G1)
{
if (diff>=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<SFM_G1G2)
{
if (diff>=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<SFM_N)
{
if (diff>=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;
}

View File

@ -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; n<N2; n++)
{
normq = dicn[idxnrm[n]];
v = R[n];
if (v>1)
{
rv = RV[v];
factor = FCT_LVQ2f / (float)rv;
for (i=0; i<nb_vecs; i++)
{
idx2code(pidx, x, v);
for (j=0; j<8; j++)
{
*pcoefs_norm = x[j] * factor + OFFSETf;
*pcoefs++ = (*pcoefs_norm++) * normq;
}
pidx += 8;
}
}
else if (v==1)
{
pre_idx = MAX16B;
for (i=0; i<nb_vecs; i++)
{
if ((pre_idx<128) && (*pidx<16))
{
for (j=0; j<8; j++)
{
*pcoefs_norm = OFFSETf;
*pcoefs++ = (*pcoefs_norm++) * normq;
}
}
else
{
for (j=0; j<8; j++)
{
*pcoefs_norm = (float)dic4[*pidx][j] / FCT_LVQ1f + OFFSETf;
*pcoefs++ = (*pcoefs_norm++) * normq;
}
}
pre_idx = *pidx;
pidx += 8;
}
}
else
{
for (i=0; i<L; i++)
{
*pcoefs_norm++ = 0.0;
*pcoefs++ = 0.0;
}
pidx += L;
}
}
return;
}

View File

@ -0,0 +1,135 @@
/*--------------------------------------------------------------------------*/
/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */
/* © 2008 Ericsson AB. and Polycom Inc. */
/* All rights reserved. */
/*--------------------------------------------------------------------------*/
#include "cnst.h"
#include "state.h"
#include "rom.h"
#include "proto.h"
#include <math.h>
/*--------------------------------------------------------------------------*/
/* 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;
}
}
}

View File

@ -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; i<NB_SFM; i++)
{
hcode_l += huffsizn[ynrm[i]];
}
pbits += hcode_l;
}
else
{
for (i=1; i<NB_SFM; i++)
{
bits2idxn(pbits, NORMI_BITS, &ynrm[i]);
pbits += NORMI_BITS;
}
hcode_l = NUMNRMIBITS;
}
/*** De-quantization of norms ***/
/* First sub-frame */
normqlg2[0] = dicnlg2[ynrm[0]];
/* Other sub-frames */
if (is_transient)
{
/* Recover quantization indices and quantized norms */
idxbuf[0] = ynrm[0];
for (i=1; i<NB_SFM; i++)
{
idxbuf[i] = ynrm[i] + idxbuf[i-1] - 15;
}
recovernorm(idxbuf, ynrm, normqlg2);
}
else
{
for (i=1; i<NB_SFM; i++)
{
j = i - 1;
k = ynrm[j] - 15;
ynrm[i] += k;
normqlg2[i] = dicnlg2[ynrm[i]];
}
}
/*** Bit allocation ***/
for (i=0; i<nb_sfm; i++)
{
idx[i] = i;
}
map_quant_weight(normqlg2, wnorm, is_transient);
reordvct(wnorm, nb_sfm, idx);
for (i=0; i<NB_SFM; i++)
{
R[i] = 0;
}
diff = NumSpectumBits - FLAGS_BITS - NORM0_BITS;
v = diff - hcode_l;
diff = v;
bitalloc(wnorm, idx, diff, nb_sfm, QBIT_MAX2, R);
/*** Unpacking bit stream and Huffman decoding for indices of quantized coefficients ***/
/* First group */
hcode_l = unpackc(R, pbits, FlagC, 0, 0, SFM_G1, WID_G1, ycof);
pbits += hcode_l;
/* Second group */
k = unpackc(R, pbits, FlagC, NUMC_G1, SFM_G1, SFM_G1G2, WID_G2, ycof);
pbits += k;
hcode_l += k;
/* Third group */
k = unpackc(R, pbits, FlagC, NUMC_G1G2, SFM_G1G2, SFM_N, WID_G3, ycof);
pbits += k;
hcode_l += k;
/* Forth group */
if (nb_sfm>SFM_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;
}

View File

@ -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<N; i++)
{
temp = 0;
if ((*pbits++)==G192_BIT1)
{
temp = 3;
if ((*pbits++)==G192_BIT1)
{
temp = 1;
if ((*pbits++)==G192_BIT1)
{
temp++;
}
}
}
*pidx++ = temp;
}
return;
}
/*--------------------------------------------------------------------------*/
/* Function hdec2blvq */
/* ~~~~~~~~~~~~~~~~~~~ */
/* */
/* Huffman decoding for indices of 3-bit LVQ2 */
/*--------------------------------------------------------------------------*/
/* short *bitstream (i) Huffman code */
/* short N (i) number of coefficients */
/* short *index (o) LVQ2 quantization indices */
/*--------------------------------------------------------------------------*/
void hdec3blvq(short *bitstream, short N, short *index)
{
short i, j, k, m;
short temp;
short *pbits, *pidx;
pbits = bitstream;
pidx = index;
for (i=0; i<N; i++)
{
j = 0;
if ((*pbits++)==G192_BIT1)
{
j = 1;
}
k = j * 2;
if ((*pbits++)==G192_BIT1)
{
k++;
}
temp = j * 4 + k;
if (k==2)
{
j = 0;
if ((*pbits++)==G192_BIT1)
{
j = 1;
}
m = j * 2;
if ((*pbits++)==G192_BIT1)
{
m++;
}
temp = j * 2 + m + 1;
if (m==0)
{
temp = 3;
if ((*pbits++)==G192_BIT1)
{
temp++;
}
}
}
*pidx++ = temp;
}
return;
}
/*--------------------------------------------------------------------------*/
/* Function hdec2blvq */
/* ~~~~~~~~~~~~~~~~~~~ */
/* */
/* Huffman decoding for indices of 4-bit LVQ2 */
/*--------------------------------------------------------------------------*/
/* short *bitstream (i) Huffman code */
/* short N (i) number of coefficients */
/* short *index (o) LVQ2 quantization indices */
/*--------------------------------------------------------------------------*/
void hdec4blvq(short *bitstream, short N, short *index)
{
short i, j, k, m;
short temp;
short *pbits, *pidx;
pbits = bitstream;
pidx = index;
for (i=0; i<N; i++)
{
k = 0;
if ((*pbits++)==G192_BIT1)
{
k = 2;
}
if ((*pbits++)==G192_BIT1)
{
k++;
}
temp = 0;
if (k!=0)
{
j = 0;
if ((*pbits++)==G192_BIT1)
{
j = 1;
}
temp = 1;
if (j!=0)
{
temp = 15;
}
if (k!=3)
{
m = j * 2;
if ((*pbits++)==G192_BIT1)
{
m++;
}
temp = m;
if (j==0)
{
temp = m + 13;
}
if (k!=1)
{
m = m * 2;
if ((*pbits++)==G192_BIT1)
{
m++;
}
temp = m;
if (j==0)
{
temp = m + 9;
}
if (m==7)
{
temp = m;
if ((*pbits++)==G192_BIT1)
{
temp = m + 1;
}
}
}
}
}
*pidx++ = temp;
}
return;
}
/*--------------------------------------------------------------------------*/
/* Function hdec2blvq */
/* ~~~~~~~~~~~~~~~~~~~ */
/* */
/* Huffman decoding for indices of 5-bit LVQ2 */
/*--------------------------------------------------------------------------*/
/* short *bitstream (i) Huffman code */
/* short N (i) number of coefficients */
/* short *index (o) LVQ2 quantization indices */
/*--------------------------------------------------------------------------*/
void hdec5blvq(short *bitstream, short N, short *index)
{
short i, j, k, m, n;
short temp;
short *pbits, *pidx;
pbits = bitstream;
pidx = index;
for (i=0; i<N; i++)
{
n = 0;
if ((*pbits++)==G192_BIT1)
{
n = 2;
}
if ((*pbits++)==G192_BIT1)
{
n++;
}
temp = 0;
if (n!=0)
{
j = 0;
if ((*pbits++)==G192_BIT1)
{
j = 1;
}
temp = 1;
if (j!=0)
{
temp = 31;
}
if (n!=1)
{
k = 0;
if ((*pbits++)==G192_BIT1)
{
k = 1;
}
if (n==2)
{
temp = 2;
if (k!=0)
{
temp = 30;
}
if (j!=0)
{
temp = 3;
if ((*pbits++)==G192_BIT1)
{
temp++;
}
if (k!=0)
{
temp += 25;
}
}
}
else
{
m = 0;
if ((*pbits++)==G192_BIT1)
{
m = 2;
}
if ((*pbits++)==G192_BIT1)
{
m++;
}
temp = m + 5;
if (k!=0)
{
temp += 19;
}
if (j!=0)
{
m = k * 4 + m;
temp = 23;
if (m!=7)
{
m *= 2;
if ((*pbits++)==G192_BIT1)
{
m++;
}
temp = m + 9;
}
}
}
}
}
*pidx++ = temp;
}
return;
}

View File

@ -0,0 +1,77 @@
/*--------------------------------------------------------------------------*/
/* ITU-T G.722.1 Fullband Extension Annex X. Source Code */
/* © 2008 Ericsson AB. and Polycom Inc. */
/* All rights reserved. */
/*--------------------------------------------------------------------------*/
#include "cnst.h"
/*--------------------------------------------------------------------------*/
/* Function hdecnrm */
/* ~~~~~~~~~~~~~~~~~ */
/* */
/* Huffman decoding for indices of quantized norms */
/*--------------------------------------------------------------------------*/
/* short *bitstream (i) Huffman code */
/* short N (i) number of norms */
/* short *index (o) indices of quantized norms */
/*--------------------------------------------------------------------------*/
void hdecnrm(short *bitstream, short N, short *index)
{
short i, j, k, n, m;
short temp;
short *pbits, *pidx;
pbits = bitstream;
pidx = index;
m = N - 1;
for (i=0; i<m; i++)
{
j = 0;
k = 0;
if ((*pbits++)==G192_BIT1)
{
j = 1;
}
if ((*pbits++)==G192_BIT1)
{
k = 1;
}
n = j * 2 + k;
j = j * 4;
temp = 16 + n - j;
if ((*pbits++)==G192_BIT1)
{
temp = 12 + n + j;
if ((*pbits++)==G192_BIT1)
{
j = 0;
if ((*pbits++)==G192_BIT1)
{
j = 1;
}
temp = 8 + n;
if (j!=0)
{
temp += 12;
}
if ((*pbits++)==G192_BIT1)
{
temp = n;
if ((*pbits++)==G192_BIT1)
{
temp = n + 4;
}
if (j!=0)
{
temp += 24;
}
}
}
}
*pidx++ = temp;
}
return;
}

View File

@ -0,0 +1,141 @@
/*--------------------------------------------------------------------------*/
/* 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"
#include "proto.h"
/*--------------------------------------------------------------------------*/
/* Function itda */
/* ~~~~~~~~~~~~~~ */
/* */
/* Inverse time domain aliasing */
/*--------------------------------------------------------------------------*/
/* float *in (i) input vector */
/* float *out (o) output vector */
/*--------------------------------------------------------------------------*/
void itda(float *in, float *out)
{
short i;
for (i = 0; i < MLT960_LENGTH_DIV_2; i++)
{
out[i] = in[MLT960_LENGTH_DIV_2 + i];
out[MLT960_LENGTH_DIV_2 + i] = -in[MLT960_LENGTH - 1 - i];
out[MLT960_LENGTH + i] = -in[MLT960_LENGTH_DIV_2 - 1 - i];
out[3*MLT960_LENGTH_DIV_2 + i] = -in[i];
}
}
/*--------------------------------------------------------------------------*/
/* Function imdct_short */
/* ~~~~~~~~~~~~~~~~~~~~~ */
/* */
/* Inverse MDCT for short frames */
/*--------------------------------------------------------------------------*/
/* float *in (i) input vector */
/* float *out (o) output vector */
/*--------------------------------------------------------------------------*/
void imdct_short(float *in, float *out)
{
float alias[MAX_SEGMENT_LENGTH];
short i;
dct4_240(in, alias);
for (i = 0; i < MAX_SEGMENT_LENGTH/4; i++)
{
out[i] = alias[MAX_SEGMENT_LENGTH/4 + i];
out[MAX_SEGMENT_LENGTH/4 + i] = -alias[MAX_SEGMENT_LENGTH/2 - 1 - i];
out[MAX_SEGMENT_LENGTH/2 + i] = -alias[MAX_SEGMENT_LENGTH/4 - 1 - i];
out[3*MAX_SEGMENT_LENGTH/4 + i] = -alias[i];
}
}
/*--------------------------------------------------------------------------*/
/* Function inverse_transform */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* */
/* Inverse transform from the DCT domain to time domain */
/*--------------------------------------------------------------------------*/
/* float *in_mdct (i) input MDCT vector */
/* float *out (o) output vector */
/* int *is_transient (o) transient flag */
/*--------------------------------------------------------------------------*/
void inverse_transform(float *in_mdct, float *out, int is_transient)
{
float out_alias[FRAME_LENGTH];
float alias[MAX_SEGMENT_LENGTH];
float *in_segment;
float *out_segment;
float tmp;
short ta, seg;
if (is_transient)
{
for (ta = 0; ta < FRAME_LENGTH; ta++)
{
out_alias[ta] = 0.0f;
}
out_segment = out_alias - MAX_SEGMENT_LENGTH / 4;
in_segment = in_mdct + 0;
imdct_short(in_segment, alias);
for (ta = MAX_SEGMENT_LENGTH /4; ta < MAX_SEGMENT_LENGTH /2; ta++)
{
out_segment[ta] = alias[ta];
}
for (ta = MAX_SEGMENT_LENGTH /2; ta < MAX_SEGMENT_LENGTH; ta++)
{
out_segment[ta] = alias[ta]*short_window[ta];
}
out_segment = out_segment + MAX_SEGMENT_LENGTH/2;
in_segment = in_segment + MAX_SEGMENT_LENGTH/2;
for (seg = 1 ; seg < NUM_TIME_SWITCHING_BLOCKS-1; seg++)
{
imdct_short(in_segment, alias);
for (ta = 0; ta < MAX_SEGMENT_LENGTH; ta++)
{
out_segment[ta] = out_segment[ta] + alias[ta] * short_window[ta];
}
in_segment = in_segment + MAX_SEGMENT_LENGTH/2;
out_segment = out_segment + MAX_SEGMENT_LENGTH/2;
}
imdct_short(in_segment, alias);
for (ta = 0; ta < MAX_SEGMENT_LENGTH /2; ta++)
{
out_segment[ta] = out_segment[ta] + alias[ta] * short_window[ta];
}
for (ta = MAX_SEGMENT_LENGTH /2; ta < MAX_SEGMENT_LENGTH /4+MAX_SEGMENT_LENGTH /2; ta++)
{
out_segment[ta] = alias[ta];
}
for (ta = 0; ta < FRAME_LENGTH/2; ta++)
{
tmp = out_alias[ta];
out_alias[ta] = out_alias[FRAME_LENGTH-1-ta];
out_alias[FRAME_LENGTH-1-ta] = tmp;
}
}
else
{
dct4_960(in_mdct, out_alias);
}
itda(out_alias, out);
}

View File

@ -0,0 +1,119 @@
/*--------------------------------------------------------------------------*/
/* 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 unpackc */
/* ~~~~~~~~~~~~~~~~~ */
/* */
/* Huffman decoding and unpacking indices for quantized coefficients */
/*--------------------------------------------------------------------------*/
/* short *R (i) number of bits per coefficinet */
/* short *pbits (i) pointer to bitstream */
/* short flag (i) Huffman code flag */
/* short rv (i) offset for index of quantized coefficients */
/* short N1 (i) beginning sub-vector's number in the group */
/* short N2 (i) ending sub-vector's number in the group */
/* short L (o) number of coefficients in each sub-vector */
/* short *y (o) indices of the selected codevectors */
/*--------------------------------------------------------------------------*/
/* short return (o) length of Huffman code */
/*--------------------------------------------------------------------------*/
short unpackc(short *R, short *pbits, short flag, short rv, short N1, short N2, short L, short *y)
{
short i, j, k, n, r, v, hcode_l, offset, sum;
short nb_vecs, length;
nb_vecs = L >> 3;
length = 0;
if (flag==NOHUFCODE)
{
for (n=N1; n<N2; n++)
{
v = R[n];
if (v>1)
{
bits2idxc(pbits, L, v, &y[rv]);
sum = v * L;
pbits += sum;
length += sum;
}
else if (v==1)
{
k = rv;
for (i=0; i<nb_vecs; i++)
{
bits2idxc(pbits, 8, 1, &y[k]);
pbits += 8;
k += 8;
}
length += L;
}
rv += L;
}
}
else
{
r = 0;
hcode_l = 0;
for (n=N1; n<N2; n++)
{
v = R[n];
if (v>QBIT_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<L; i++)
{
k = rv + i;
j = offset + y[k];
hcode_l += huffsizc[j];
pbits += huffsizc[j];
}
}
else if (v==1)
{
k = rv;
for (i=0; i<nb_vecs; i++)
{
bits2idxc(pbits, 8, 1, &y[k]);
pbits += 8;
k += 8;
}
r += L;
}
rv += L;
}
length = hcode_l + r;
}
return(length);
}

View File

@ -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 "cnst.h"
/*--------------------------------------------------------------------------*/
/* Function window_ola */
/* ~~~~~~~~~~~~~~~~~~~~ */
/* */
/* Windowing, Overlap and Add */
/*--------------------------------------------------------------------------*/
/* float ImdctOut[] (i) input */
/* short auOut[] (o) output audio */
/* float OldauOut[] (i/o) audio from previous frame */
/*--------------------------------------------------------------------------*/
void window_ola(float ImdctOut[], short auOut[], float OldauOut[])
{
short i;
float OutputVal;
float ImdctOutWin[2*FRAME_LENGTH];
for (i=0 ; i < 2*FRAME_LENGTH ; i++)
{
ImdctOutWin[i] = ImdctOut[i] * window[i];
}
for (i=0 ; i < FRAME_LENGTH ; i++)
{
OutputVal = ImdctOutWin[i] + OldauOut[i];
if (OutputVal > 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];
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <stdio.h>
#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

View File

@ -0,0 +1,112 @@
/* Copyright (C) 2002-2003 Jean-Marc Valin
Copyright (C) 2007-2009 Xiph.Org Foundation */
/**
@file stack_alloc.h
@brief Temporary memory allocation on stack
*/
/*
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef STACK_ALLOC_H
#define STACK_ALLOC_H
#if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA))
#error "Vgmstream requires one of VAR_ARRAYS or USE_ALLOCA be defined to select the temporary allocation mode."
#endif
#ifdef USE_ALLOCA
# ifdef WIN32
# include <malloc.h>
# else
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# else
# include <stdlib.h>
# endif
# endif
#endif
/**
* @def ALIGN(stack, size)
*
* Aligns the stack to a 'size' boundary
*
* @param stack Stack
* @param size New size boundary
*/
/**
* @def PUSH(stack, size, type)
*
* Allocates 'size' elements of type 'type' on the stack
*
* @param stack Stack
* @param size Number of elements
* @param type Type of element
*/
/**
* @def VARDECL(var)
*
* Declare variable on stack
*
* @param var Variable to declare
*/
/**
* @def ALLOC(var, size, type)
*
* Allocate 'size' elements of 'type' on stack
*
* @param var Name of variable to allocate
* @param size Number of elements
* @param type Type of element
*/
#if defined(VAR_ARRAYS)
#define VARDECL(type, var)
#define ALLOC(var, size, type) type var[size]
#define SAVE_STACK
#define RESTORE_STACK
#define ALLOC_STACK
#elif defined(USE_ALLOCA)
#define VARDECL(type, var) type *var
# ifdef WIN32
# define ALLOC(var, size, type) var = ((type*)_alloca(sizeof(type)*(size)))
# else
# define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size)))
# endif
#define SAVE_STACK
#define RESTORE_STACK
#define ALLOC_STACK
#endif /* VAR_ARRAYS */
#endif /* STACK_ALLOC_H */

View File

@ -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 = "<group>"; };
83D730F21A738F4E00CA1366 /* common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = common.c; sourceTree = "<group>"; };
83D730F31A738F4E00CA1366 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; };
83D730F41A738F4E00CA1366 /* dct4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dct4.c; sourceTree = "<group>"; };
83D730F51A738F4E00CA1366 /* dct4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dct4.h; sourceTree = "<group>"; };
83D730F61A738F4E00CA1366 /* decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = decoder.c; sourceTree = "<group>"; };
83D730F71A738F4E00CA1366 /* decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decoder.h; sourceTree = "<group>"; };
83D730F81A738F4E00CA1366 /* huffman.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = huffman.c; sourceTree = "<group>"; };
83D730F91A738F4E00CA1366 /* huffman.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = huffman.h; sourceTree = "<group>"; };
83D730FA1A738F4E00CA1366 /* huffman_consts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = huffman_consts.h; sourceTree = "<group>"; };
83D730FB1A738F4E00CA1366 /* rmlt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rmlt.c; sourceTree = "<group>"; };
83D730FC1A738F4E00CA1366 /* rmlt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rmlt.h; sourceTree = "<group>"; };
83D730FD1A738F4E00CA1366 /* siren7.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = siren7.h; sourceTree = "<group>"; };
83D730FE1A738F4E00CA1366 /* g7221.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = g7221.h; sourceTree = "<group>"; };
83D7310C1A738F8500CA1366 /* g7221.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g7221.c; sourceTree = "<group>"; };
/* 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 = "<group>";
};
83D730CA1A738EB200CA1366 /* Products */ = {
isa = PBXGroup;
children = (
83D730C91A738EB200CA1366 /* g7221.framework */,
);
name = Products;
sourceTree = "<group>";
};
83D730CB1A738EB200CA1366 /* g7221 */ = {
isa = PBXGroup;
children = (
83D730F11A738F4E00CA1366 /* libsiren */,
83D730FE1A738F4E00CA1366 /* g7221.h */,
83D730CC1A738EB200CA1366 /* Supporting Files */,
83D7310C1A738F8500CA1366 /* g7221.c */,
);
path = g7221;
sourceTree = "<group>";
};
83D730CC1A738EB200CA1366 /* Supporting Files */ = {
isa = PBXGroup;
children = (
83D730CD1A738EB200CA1366 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
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 = "<group>";
};
/* 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 */;
}

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.cogx.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Christopher Snowhill. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

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

23
Frameworks/g7221/g7221/g7221.h Executable file
View File

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

View File

@ -0,0 +1,529 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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;
}

View File

@ -0,0 +1,146 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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 */

View File

@ -0,0 +1,199 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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;
}
}

View File

@ -0,0 +1,30 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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_ */

View File

@ -0,0 +1,273 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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;
}

View File

@ -0,0 +1,63 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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 <math.h>
#include <stdlib.h>
#include <string.h>
#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 */

View File

@ -0,0 +1,267 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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;
}

View File

@ -0,0 +1,60 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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 <math.h>
#include <stdlib.h>
#include <string.h>
#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 */

View File

@ -0,0 +1,425 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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;
}

View File

@ -0,0 +1,42 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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_ */

View File

@ -0,0 +1,528 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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 */

View File

@ -0,0 +1,149 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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;
}

View File

@ -0,0 +1,30 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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_ */

View File

@ -0,0 +1,36 @@
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* 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 */

View File

@ -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 = "<group>"; };
83A5F75E198DF021009AF94C /* bfwav.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bfwav.c; sourceTree = "<group>"; };
83BAFB6B19F45EB3005DAB60 /* bfstm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bfstm.c; sourceTree = "<group>"; };
83D730E51A738EB200CA1366 /* g7221.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = g7221.xcodeproj; path = ../g7221/g7221.xcodeproj; sourceTree = "<group>"; };
83D731381A74968900CA1366 /* g719.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = g719.xcodeproj; path = ../g719/g719.xcodeproj; sourceTree = "<group>"; };
83D7318B1A749EEE00CA1366 /* g719_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g719_decoder.c; sourceTree = "<group>"; };
83EDE5D61A70951A005F5D84 /* mca.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = mca.c; sourceTree = "<group>"; };
83EDE5D71A70951A005F5D84 /* btsnd.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = btsnd.c; sourceTree = "<group>"; };
83F5F8821908D0A400C8E65F /* fsb5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fsb5.c; sourceTree = "<group>"; };
@ -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 = "<group>";
@ -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 = "<group>";
};
83D730E61A738EB200CA1366 /* Products */ = {
isa = PBXGroup;
children = (
83D730EB1A738EB300CA1366 /* g7221.framework */,
);
name = Products;
sourceTree = "<group>";
};
83D731391A74968900CA1366 /* Products */ = {
isa = PBXGroup;
children = (
83D7313E1A74968A00CA1366 /* g719.framework */,
);
name = Products;
sourceTree = "<group>";
};
/* 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 */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -465,6 +465,18 @@ void reset_vgmstream(VGMSTREAM * vgmstream) {
}
#endif
#ifdef VGM_USE_G719
if (vgmstream->coding_type==coding_G719) {
g719_codec_data *data = vgmstream->codec_data;
int i;
for (i = 0; i < vgmstream->channels; i++)
{
g719_reset(data[i].handle);
}
}
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
if (vgmstream->coding_type==coding_AT3plus) {
maiatrac3plus_codec_data *data = vgmstream->codec_data;
@ -664,6 +676,25 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
}
#endif
#ifdef VGM_USE_G719
if (vgmstream->coding_type == coding_G719) {
g719_codec_data *data = vgmstream->codec_data;
if (data)
{
int i;
for (i = 0; i < vgmstream->channels; i++)
{
g719_free(data[i].handle);
}
free(data);
}
vgmstream->codec_data = NULL;
}
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
if (vgmstream->coding_type == coding_AT3plus) {
maiatrac3plus_codec_data *data = vgmstream->codec_data;
@ -978,6 +1009,10 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
return 32000/50;
case coding_G7221:
return 16000/50;
#endif
#ifdef VGM_USE_G719
case coding_G719:
return 48000/50;
#endif
case coding_LSF:
return 54;
@ -1086,6 +1121,9 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
case coding_G7221C:
case coding_G7221:
#endif
#ifdef VGM_USE_G719:
case coding_G719:
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
case coding_AT3plus:
#endif
@ -1475,6 +1513,17 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
}
break;
#endif
#ifdef VGM_USE_G719
case coding_G719:
for (chan=0;chan<vgmstream->channels;chan++) {
decode_g719(vgmstream,
buffer+samples_written*vgmstream->channels+chan,
vgmstream->channels,
samples_to_do,
chan);
}
break;
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
case coding_AT3plus:
for (chan=0;chan<vgmstream->channels;chan++) {
@ -1921,6 +1970,11 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
snprintf(temp,TEMPSIZE,"ITU G.722.1 annex C (Polycom Siren 14)");
break;
#endif
#ifdef VGM_USE_G719
case coding_G719:
snprintf(temp,TEMPSIZE,"ITU G.719 annex B (Polycom Siren 22)");
break;
#endif
#ifdef VGM_USE_MAIATRAC3PLUS
case coding_AT3plus:
snprintf(temp,TEMPSIZE,"ATRAC3plus");

View File

@ -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 <mpg123/mpg123.h>
#endif
#ifdef VGM_USE_G7221
#include "g7221.h"
#include <g7221/g7221.h>
#endif
#ifdef VGM_USE_G719
#include <g719/g719.h>
#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;