├── ESCAACCoderDemo ├── ESCAACCoderDemo.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcuserdata │ │ │ └── xiang.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── xiang.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ └── xcschememanagement.plist └── ESCAACCoderDemo │ ├── 8000_16_1.aac │ ├── 8000_16_1_1.pcm │ ├── 8000_1_16.pcm │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── ESCAACEncoder.h │ ├── ESCAACEncoder.m │ ├── ESCFAACDecoder.h │ ├── ESCFAACDecoder.m │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ ├── faac │ ├── include │ │ ├── faac.h │ │ └── faaccfg.h │ └── lib │ │ └── libfaac.a │ ├── faad │ ├── include │ │ ├── faad.h │ │ ├── mp4ff.h │ │ ├── mp4ffint.h │ │ └── neaacdec.h │ └── lib │ │ ├── libfaad.a │ │ └── libmp4ff.a │ ├── main.m │ ├── vocal.aac │ └── vocal.pcm └── README.md /ESCAACCoderDemo/ESCAACCoderDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F02338A1216C452400785305 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F02338A0216C452400785305 /* AppDelegate.m */; }; 11 | F02338A4216C452400785305 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F02338A3216C452400785305 /* ViewController.m */; }; 12 | F02338A7216C452400785305 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F02338A5216C452400785305 /* Main.storyboard */; }; 13 | F02338A9216C452B00785305 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F02338A8216C452B00785305 /* Assets.xcassets */; }; 14 | F02338AC216C452B00785305 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F02338AA216C452B00785305 /* LaunchScreen.storyboard */; }; 15 | F02338AF216C452B00785305 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F02338AE216C452B00785305 /* main.m */; }; 16 | F02338BB216C8DB500785305 /* libfaac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F02338BA216C8DB500785305 /* libfaac.a */; }; 17 | F02338C5216C8DB900785305 /* libfaad.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F02338C3216C8DB900785305 /* libfaad.a */; }; 18 | F02338C6216C8DBA00785305 /* libmp4ff.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F02338C4216C8DB900785305 /* libmp4ff.a */; }; 19 | F02338C8216C8F3A00785305 /* vocal.pcm in Resources */ = {isa = PBXBuildFile; fileRef = F02338C7216C8F3A00785305 /* vocal.pcm */; }; 20 | F02338CA216C995100785305 /* vocal.aac in Resources */ = {isa = PBXBuildFile; fileRef = F02338C9216C995100785305 /* vocal.aac */; }; 21 | F02338CD216C9A7200785305 /* ESCFAACDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = F02338CB216C9A7200785305 /* ESCFAACDecoder.m */; }; 22 | F02338D0216CA28A00785305 /* ESCAACEncoder.m in Sources */ = {isa = PBXBuildFile; fileRef = F02338CF216CA28A00785305 /* ESCAACEncoder.m */; }; 23 | F064FEA82192C80900A6F58C /* 8000_16_1.aac in Resources */ = {isa = PBXBuildFile; fileRef = F064FEA72192C80800A6F58C /* 8000_16_1.aac */; }; 24 | F0762A85217F069500442B9C /* 8000_1_16.pcm in Resources */ = {isa = PBXBuildFile; fileRef = F0762A84217F069400442B9C /* 8000_1_16.pcm */; }; 25 | F0EA67792180606000D1FCE2 /* 8000_16_1_1.pcm in Resources */ = {isa = PBXBuildFile; fileRef = F0EA67782180606000D1FCE2 /* 8000_16_1_1.pcm */; }; 26 | F0F141C92178532000C883F8 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = F0F141C82178532000C883F8 /* libc++.tbd */; }; 27 | /* End PBXBuildFile section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | F023389C216C452400785305 /* ESCAACCoderDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ESCAACCoderDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | F023389F216C452400785305 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 32 | F02338A0216C452400785305 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 33 | F02338A2216C452400785305 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 34 | F02338A3216C452400785305 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 35 | F02338A6216C452400785305 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | F02338A8216C452B00785305 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 37 | F02338AB216C452B00785305 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 38 | F02338AD216C452B00785305 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | F02338AE216C452B00785305 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 40 | F02338B7216C8DB500785305 /* faac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = faac.h; sourceTree = ""; }; 41 | F02338B8216C8DB500785305 /* faaccfg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = faaccfg.h; sourceTree = ""; }; 42 | F02338BA216C8DB500785305 /* libfaac.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfaac.a; sourceTree = ""; }; 43 | F02338BE216C8DB900785305 /* faad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = faad.h; sourceTree = ""; }; 44 | F02338BF216C8DB900785305 /* mp4ff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mp4ff.h; sourceTree = ""; }; 45 | F02338C0216C8DB900785305 /* mp4ffint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mp4ffint.h; sourceTree = ""; }; 46 | F02338C1216C8DB900785305 /* neaacdec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = neaacdec.h; sourceTree = ""; }; 47 | F02338C3216C8DB900785305 /* libfaad.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libfaad.a; sourceTree = ""; }; 48 | F02338C4216C8DB900785305 /* libmp4ff.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libmp4ff.a; sourceTree = ""; }; 49 | F02338C7216C8F3A00785305 /* vocal.pcm */ = {isa = PBXFileReference; lastKnownFileType = file; path = vocal.pcm; sourceTree = ""; }; 50 | F02338C9216C995100785305 /* vocal.aac */ = {isa = PBXFileReference; lastKnownFileType = file; path = vocal.aac; sourceTree = ""; }; 51 | F02338CB216C9A7200785305 /* ESCFAACDecoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ESCFAACDecoder.m; sourceTree = ""; }; 52 | F02338CC216C9A7200785305 /* ESCFAACDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ESCFAACDecoder.h; sourceTree = ""; }; 53 | F02338CE216CA28A00785305 /* ESCAACEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ESCAACEncoder.h; sourceTree = ""; }; 54 | F02338CF216CA28A00785305 /* ESCAACEncoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ESCAACEncoder.m; sourceTree = ""; }; 55 | F064FEA72192C80800A6F58C /* 8000_16_1.aac */ = {isa = PBXFileReference; lastKnownFileType = file; path = 8000_16_1.aac; sourceTree = ""; }; 56 | F0762A84217F069400442B9C /* 8000_1_16.pcm */ = {isa = PBXFileReference; lastKnownFileType = file; path = 8000_1_16.pcm; sourceTree = ""; }; 57 | F0EA67782180606000D1FCE2 /* 8000_16_1_1.pcm */ = {isa = PBXFileReference; lastKnownFileType = file; path = 8000_16_1_1.pcm; sourceTree = ""; }; 58 | F0F141C82178532000C883F8 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; 59 | /* End PBXFileReference section */ 60 | 61 | /* Begin PBXFrameworksBuildPhase section */ 62 | F0233899216C452400785305 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | F0F141C92178532000C883F8 /* libc++.tbd in Frameworks */, 67 | F02338C6216C8DBA00785305 /* libmp4ff.a in Frameworks */, 68 | F02338BB216C8DB500785305 /* libfaac.a in Frameworks */, 69 | F02338C5216C8DB900785305 /* libfaad.a in Frameworks */, 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | /* End PBXFrameworksBuildPhase section */ 74 | 75 | /* Begin PBXGroup section */ 76 | F0233893216C452400785305 = { 77 | isa = PBXGroup; 78 | children = ( 79 | F023389E216C452400785305 /* ESCAACCoderDemo */, 80 | F023389D216C452400785305 /* Products */, 81 | F0F141C72178531F00C883F8 /* Frameworks */, 82 | ); 83 | sourceTree = ""; 84 | }; 85 | F023389D216C452400785305 /* Products */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | F023389C216C452400785305 /* ESCAACCoderDemo.app */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | F023389E216C452400785305 /* ESCAACCoderDemo */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | F0EA67782180606000D1FCE2 /* 8000_16_1_1.pcm */, 97 | F0762A84217F069400442B9C /* 8000_1_16.pcm */, 98 | F02338C7216C8F3A00785305 /* vocal.pcm */, 99 | F02338C9216C995100785305 /* vocal.aac */, 100 | F064FEA72192C80800A6F58C /* 8000_16_1.aac */, 101 | F02338BC216C8DB900785305 /* faad */, 102 | F02338B5216C8DB500785305 /* faac */, 103 | F023389F216C452400785305 /* AppDelegate.h */, 104 | F02338A0216C452400785305 /* AppDelegate.m */, 105 | F02338A2216C452400785305 /* ViewController.h */, 106 | F02338A3216C452400785305 /* ViewController.m */, 107 | F02338A5216C452400785305 /* Main.storyboard */, 108 | F02338CE216CA28A00785305 /* ESCAACEncoder.h */, 109 | F02338CF216CA28A00785305 /* ESCAACEncoder.m */, 110 | F02338CC216C9A7200785305 /* ESCFAACDecoder.h */, 111 | F02338CB216C9A7200785305 /* ESCFAACDecoder.m */, 112 | F02338A8216C452B00785305 /* Assets.xcassets */, 113 | F02338AA216C452B00785305 /* LaunchScreen.storyboard */, 114 | F02338AD216C452B00785305 /* Info.plist */, 115 | F02338AE216C452B00785305 /* main.m */, 116 | ); 117 | path = ESCAACCoderDemo; 118 | sourceTree = ""; 119 | }; 120 | F02338B5216C8DB500785305 /* faac */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | F02338B6216C8DB500785305 /* include */, 124 | F02338B9216C8DB500785305 /* lib */, 125 | ); 126 | path = faac; 127 | sourceTree = ""; 128 | }; 129 | F02338B6216C8DB500785305 /* include */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | F02338B7216C8DB500785305 /* faac.h */, 133 | F02338B8216C8DB500785305 /* faaccfg.h */, 134 | ); 135 | path = include; 136 | sourceTree = ""; 137 | }; 138 | F02338B9216C8DB500785305 /* lib */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | F02338BA216C8DB500785305 /* libfaac.a */, 142 | ); 143 | path = lib; 144 | sourceTree = ""; 145 | }; 146 | F02338BC216C8DB900785305 /* faad */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | F02338BD216C8DB900785305 /* include */, 150 | F02338C2216C8DB900785305 /* lib */, 151 | ); 152 | path = faad; 153 | sourceTree = ""; 154 | }; 155 | F02338BD216C8DB900785305 /* include */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | F02338BE216C8DB900785305 /* faad.h */, 159 | F02338BF216C8DB900785305 /* mp4ff.h */, 160 | F02338C0216C8DB900785305 /* mp4ffint.h */, 161 | F02338C1216C8DB900785305 /* neaacdec.h */, 162 | ); 163 | path = include; 164 | sourceTree = ""; 165 | }; 166 | F02338C2216C8DB900785305 /* lib */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | F02338C3216C8DB900785305 /* libfaad.a */, 170 | F02338C4216C8DB900785305 /* libmp4ff.a */, 171 | ); 172 | path = lib; 173 | sourceTree = ""; 174 | }; 175 | F0F141C72178531F00C883F8 /* Frameworks */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | F0F141C82178532000C883F8 /* libc++.tbd */, 179 | ); 180 | name = Frameworks; 181 | sourceTree = ""; 182 | }; 183 | /* End PBXGroup section */ 184 | 185 | /* Begin PBXNativeTarget section */ 186 | F023389B216C452400785305 /* ESCAACCoderDemo */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = F02338B2216C452B00785305 /* Build configuration list for PBXNativeTarget "ESCAACCoderDemo" */; 189 | buildPhases = ( 190 | F0233898216C452400785305 /* Sources */, 191 | F0233899216C452400785305 /* Frameworks */, 192 | F023389A216C452400785305 /* Resources */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | ); 198 | name = ESCAACCoderDemo; 199 | productName = ESCAACCoderDemo; 200 | productReference = F023389C216C452400785305 /* ESCAACCoderDemo.app */; 201 | productType = "com.apple.product-type.application"; 202 | }; 203 | /* End PBXNativeTarget section */ 204 | 205 | /* Begin PBXProject section */ 206 | F0233894216C452400785305 /* Project object */ = { 207 | isa = PBXProject; 208 | attributes = { 209 | LastUpgradeCheck = 1000; 210 | ORGANIZATIONNAME = xiang; 211 | TargetAttributes = { 212 | F023389B216C452400785305 = { 213 | CreatedOnToolsVersion = 10.0; 214 | }; 215 | }; 216 | }; 217 | buildConfigurationList = F0233897216C452400785305 /* Build configuration list for PBXProject "ESCAACCoderDemo" */; 218 | compatibilityVersion = "Xcode 9.3"; 219 | developmentRegion = en; 220 | hasScannedForEncodings = 0; 221 | knownRegions = ( 222 | en, 223 | Base, 224 | ); 225 | mainGroup = F0233893216C452400785305; 226 | productRefGroup = F023389D216C452400785305 /* Products */; 227 | projectDirPath = ""; 228 | projectRoot = ""; 229 | targets = ( 230 | F023389B216C452400785305 /* ESCAACCoderDemo */, 231 | ); 232 | }; 233 | /* End PBXProject section */ 234 | 235 | /* Begin PBXResourcesBuildPhase section */ 236 | F023389A216C452400785305 /* Resources */ = { 237 | isa = PBXResourcesBuildPhase; 238 | buildActionMask = 2147483647; 239 | files = ( 240 | F0EA67792180606000D1FCE2 /* 8000_16_1_1.pcm in Resources */, 241 | F02338C8216C8F3A00785305 /* vocal.pcm in Resources */, 242 | F02338AC216C452B00785305 /* LaunchScreen.storyboard in Resources */, 243 | F02338A9216C452B00785305 /* Assets.xcassets in Resources */, 244 | F0762A85217F069500442B9C /* 8000_1_16.pcm in Resources */, 245 | F02338CA216C995100785305 /* vocal.aac in Resources */, 246 | F064FEA82192C80900A6F58C /* 8000_16_1.aac in Resources */, 247 | F02338A7216C452400785305 /* Main.storyboard in Resources */, 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXResourcesBuildPhase section */ 252 | 253 | /* Begin PBXSourcesBuildPhase section */ 254 | F0233898216C452400785305 /* Sources */ = { 255 | isa = PBXSourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | F02338A4216C452400785305 /* ViewController.m in Sources */, 259 | F02338D0216CA28A00785305 /* ESCAACEncoder.m in Sources */, 260 | F02338CD216C9A7200785305 /* ESCFAACDecoder.m in Sources */, 261 | F02338AF216C452B00785305 /* main.m in Sources */, 262 | F02338A1216C452400785305 /* AppDelegate.m in Sources */, 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | }; 266 | /* End PBXSourcesBuildPhase section */ 267 | 268 | /* Begin PBXVariantGroup section */ 269 | F02338A5216C452400785305 /* Main.storyboard */ = { 270 | isa = PBXVariantGroup; 271 | children = ( 272 | F02338A6216C452400785305 /* Base */, 273 | ); 274 | name = Main.storyboard; 275 | sourceTree = ""; 276 | }; 277 | F02338AA216C452B00785305 /* LaunchScreen.storyboard */ = { 278 | isa = PBXVariantGroup; 279 | children = ( 280 | F02338AB216C452B00785305 /* Base */, 281 | ); 282 | name = LaunchScreen.storyboard; 283 | sourceTree = ""; 284 | }; 285 | /* End PBXVariantGroup section */ 286 | 287 | /* Begin XCBuildConfiguration section */ 288 | F02338B0216C452B00785305 /* Debug */ = { 289 | isa = XCBuildConfiguration; 290 | buildSettings = { 291 | ALWAYS_SEARCH_USER_PATHS = NO; 292 | CLANG_ANALYZER_NONNULL = YES; 293 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 294 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 295 | CLANG_CXX_LIBRARY = "libc++"; 296 | CLANG_ENABLE_MODULES = YES; 297 | CLANG_ENABLE_OBJC_ARC = YES; 298 | CLANG_ENABLE_OBJC_WEAK = YES; 299 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 300 | CLANG_WARN_BOOL_CONVERSION = YES; 301 | CLANG_WARN_COMMA = YES; 302 | CLANG_WARN_CONSTANT_CONVERSION = YES; 303 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 304 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 305 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 306 | CLANG_WARN_EMPTY_BODY = YES; 307 | CLANG_WARN_ENUM_CONVERSION = YES; 308 | CLANG_WARN_INFINITE_RECURSION = YES; 309 | CLANG_WARN_INT_CONVERSION = YES; 310 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 311 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 312 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 313 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 314 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 315 | CLANG_WARN_STRICT_PROTOTYPES = YES; 316 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 317 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 318 | CLANG_WARN_UNREACHABLE_CODE = YES; 319 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 320 | CODE_SIGN_IDENTITY = "iPhone Developer"; 321 | COPY_PHASE_STRIP = NO; 322 | DEBUG_INFORMATION_FORMAT = dwarf; 323 | ENABLE_STRICT_OBJC_MSGSEND = YES; 324 | ENABLE_TESTABILITY = YES; 325 | GCC_C_LANGUAGE_STANDARD = gnu11; 326 | GCC_DYNAMIC_NO_PIC = NO; 327 | GCC_NO_COMMON_BLOCKS = YES; 328 | GCC_OPTIMIZATION_LEVEL = 0; 329 | GCC_PREPROCESSOR_DEFINITIONS = ( 330 | "DEBUG=1", 331 | "$(inherited)", 332 | ); 333 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 334 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 335 | GCC_WARN_UNDECLARED_SELECTOR = YES; 336 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 337 | GCC_WARN_UNUSED_FUNCTION = YES; 338 | GCC_WARN_UNUSED_VARIABLE = YES; 339 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 340 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 341 | MTL_FAST_MATH = YES; 342 | ONLY_ACTIVE_ARCH = YES; 343 | SDKROOT = iphoneos; 344 | }; 345 | name = Debug; 346 | }; 347 | F02338B1216C452B00785305 /* Release */ = { 348 | isa = XCBuildConfiguration; 349 | buildSettings = { 350 | ALWAYS_SEARCH_USER_PATHS = NO; 351 | CLANG_ANALYZER_NONNULL = YES; 352 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 353 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 354 | CLANG_CXX_LIBRARY = "libc++"; 355 | CLANG_ENABLE_MODULES = YES; 356 | CLANG_ENABLE_OBJC_ARC = YES; 357 | CLANG_ENABLE_OBJC_WEAK = YES; 358 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 359 | CLANG_WARN_BOOL_CONVERSION = YES; 360 | CLANG_WARN_COMMA = YES; 361 | CLANG_WARN_CONSTANT_CONVERSION = YES; 362 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 363 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 364 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 365 | CLANG_WARN_EMPTY_BODY = YES; 366 | CLANG_WARN_ENUM_CONVERSION = YES; 367 | CLANG_WARN_INFINITE_RECURSION = YES; 368 | CLANG_WARN_INT_CONVERSION = YES; 369 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 370 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 371 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 372 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 373 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 374 | CLANG_WARN_STRICT_PROTOTYPES = YES; 375 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 376 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 377 | CLANG_WARN_UNREACHABLE_CODE = YES; 378 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 379 | CODE_SIGN_IDENTITY = "iPhone Developer"; 380 | COPY_PHASE_STRIP = NO; 381 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 382 | ENABLE_NS_ASSERTIONS = NO; 383 | ENABLE_STRICT_OBJC_MSGSEND = YES; 384 | GCC_C_LANGUAGE_STANDARD = gnu11; 385 | GCC_NO_COMMON_BLOCKS = YES; 386 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 387 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 388 | GCC_WARN_UNDECLARED_SELECTOR = YES; 389 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 390 | GCC_WARN_UNUSED_FUNCTION = YES; 391 | GCC_WARN_UNUSED_VARIABLE = YES; 392 | IPHONEOS_DEPLOYMENT_TARGET = 12.0; 393 | MTL_ENABLE_DEBUG_INFO = NO; 394 | MTL_FAST_MATH = YES; 395 | SDKROOT = iphoneos; 396 | VALIDATE_PRODUCT = YES; 397 | }; 398 | name = Release; 399 | }; 400 | F02338B3216C452B00785305 /* Debug */ = { 401 | isa = XCBuildConfiguration; 402 | buildSettings = { 403 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 404 | CODE_SIGN_STYLE = Automatic; 405 | DEVELOPMENT_TEAM = NZ6KCMA9HH; 406 | ENABLE_BITCODE = NO; 407 | INFOPLIST_FILE = ESCAACCoderDemo/Info.plist; 408 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 409 | LD_RUNPATH_SEARCH_PATHS = ( 410 | "$(inherited)", 411 | "@executable_path/Frameworks", 412 | ); 413 | LIBRARY_SEARCH_PATHS = ( 414 | "$(inherited)", 415 | "$(PROJECT_DIR)/ESCAACCoderDemo/faac/lib", 416 | "$(PROJECT_DIR)/ESCAACCoderDemo/faad/lib", 417 | ); 418 | PRODUCT_BUNDLE_IDENTIFIER = com.xiang.ESCAACCoderDemo; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | TARGETED_DEVICE_FAMILY = "1,2"; 421 | }; 422 | name = Debug; 423 | }; 424 | F02338B4216C452B00785305 /* Release */ = { 425 | isa = XCBuildConfiguration; 426 | buildSettings = { 427 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 428 | CODE_SIGN_STYLE = Automatic; 429 | DEVELOPMENT_TEAM = NZ6KCMA9HH; 430 | ENABLE_BITCODE = NO; 431 | INFOPLIST_FILE = ESCAACCoderDemo/Info.plist; 432 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 433 | LD_RUNPATH_SEARCH_PATHS = ( 434 | "$(inherited)", 435 | "@executable_path/Frameworks", 436 | ); 437 | LIBRARY_SEARCH_PATHS = ( 438 | "$(inherited)", 439 | "$(PROJECT_DIR)/ESCAACCoderDemo/faac/lib", 440 | "$(PROJECT_DIR)/ESCAACCoderDemo/faad/lib", 441 | ); 442 | PRODUCT_BUNDLE_IDENTIFIER = com.xiang.ESCAACCoderDemo; 443 | PRODUCT_NAME = "$(TARGET_NAME)"; 444 | TARGETED_DEVICE_FAMILY = "1,2"; 445 | }; 446 | name = Release; 447 | }; 448 | /* End XCBuildConfiguration section */ 449 | 450 | /* Begin XCConfigurationList section */ 451 | F0233897216C452400785305 /* Build configuration list for PBXProject "ESCAACCoderDemo" */ = { 452 | isa = XCConfigurationList; 453 | buildConfigurations = ( 454 | F02338B0216C452B00785305 /* Debug */, 455 | F02338B1216C452B00785305 /* Release */, 456 | ); 457 | defaultConfigurationIsVisible = 0; 458 | defaultConfigurationName = Release; 459 | }; 460 | F02338B2216C452B00785305 /* Build configuration list for PBXNativeTarget "ESCAACCoderDemo" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | F02338B3216C452B00785305 /* Debug */, 464 | F02338B4216C452B00785305 /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | defaultConfigurationName = Release; 468 | }; 469 | /* End XCConfigurationList section */ 470 | }; 471 | rootObject = F0233894216C452400785305 /* Project object */; 472 | } 473 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo.xcodeproj/project.xcworkspace/xcuserdata/xiang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo.xcodeproj/project.xcworkspace/xcuserdata/xiang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo.xcodeproj/xcuserdata/xiang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo.xcodeproj/xcuserdata/xiang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ESCAACCoderDemo.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | ESCAACCoderDemo.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/8000_16_1.aac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo/8000_16_1.aac -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/8000_16_1_1.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo/8000_16_1_1.pcm -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/8000_1_16.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo/8000_1_16.pcm -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/ESCAACEncoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESCAACEncoder.h 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | NS_ASSUME_NONNULL_BEGIN 12 | 13 | @interface ESCAACEncoder : NSObject 14 | 15 | - (void)setupEncoderWithSampleRate:(int)sampleRate channels:(int)channels sampleBit:(int)sampleBit; 16 | 17 | - (NSData *)encodePCMDataWithPCMData:(NSData *)pcmData; 18 | 19 | - (void)closeEncoder; 20 | 21 | 22 | @end 23 | 24 | NS_ASSUME_NONNULL_END 25 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/ESCAACEncoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // ESCAACEncoder.m 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #import "ESCAACEncoder.h" 10 | #import "faac/include/faac.h" 11 | 12 | @interface ESCAACEncoder () 13 | 14 | @property(nonatomic,assign)faacEncHandle encoder; 15 | 16 | @property(nonatomic,assign) faacEncConfigurationPtr pConfiguration;//aac设置指针 17 | 18 | @property(nonatomic,assign)int inputSamples; 19 | 20 | @property(nonatomic,assign)int inputBytes; 21 | 22 | @property(nonatomic,assign)int maxOutputBytes; 23 | 24 | @end 25 | 26 | @implementation ESCAACEncoder 27 | 28 | - (void)setupEncoderWithSampleRate:(int)sampleRate channels:(int)channels sampleBit:(int)sampleBit{ 29 | unsigned long inputSamples; 30 | unsigned long maxOutputBytes; 31 | //初始化aac句柄,同时获取最大输入样本,及编码所需最小字节 32 | faacEncHandle encoder = faacEncOpen(sampleRate, channels, &inputSamples, &maxOutputBytes); 33 | self.encoder = encoder; 34 | 35 | self.inputSamples = (int)inputSamples; 36 | self.maxOutputBytes = (int)maxOutputBytes; 37 | 38 | int nMaxInputBytes = (int)inputSamples * sampleBit / 8; 39 | self.inputBytes = nMaxInputBytes; 40 | 41 | // (2.1) Get current encoding configuration 42 | self.pConfiguration = faacEncGetCurrentConfiguration(self.encoder);//获取配置结构指针 43 | self.pConfiguration->inputFormat = FAAC_INPUT_16BIT; 44 | self.pConfiguration->outputFormat=1; 45 | self.pConfiguration->useTns=true; 46 | self.pConfiguration->useLfe=false; 47 | self.pConfiguration->aacObjectType=LOW; 48 | self.pConfiguration->shortctl=SHORTCTL_NORMAL; 49 | self.pConfiguration->quantqual=100; 50 | self.pConfiguration->bandWidth=0; 51 | self.pConfiguration->bitRate=0; 52 | // (2.2) Set encoding configuration 53 | int nRet = faacEncSetConfiguration(self.encoder, self.pConfiguration);//设置配置,根据不同设置,耗时不一样 54 | 55 | if (nRet < 0) { 56 | NSLog(@"set failed!"); 57 | } 58 | 59 | 60 | } 61 | 62 | - (NSData *)encodePCMDataWithPCMData:(NSData *)pcmData { 63 | 64 | int8_t *pPcmData = [pcmData bytes]; 65 | unsigned char *outputBuffer[self.maxOutputBytes]; 66 | 67 | NSMutableData *temData = [NSMutableData data]; 68 | int i = 0; 69 | while (1) { 70 | //读取 71 | int32_t *inputBuffer = &pPcmData[i]; 72 | //编码 73 | int outLength = faacEncEncode(self.encoder, inputBuffer, self.inputSamples, outputBuffer, self.maxOutputBytes); 74 | //组装数据 75 | if (outLength > 0) { 76 | [temData appendBytes:outputBuffer length:outLength]; 77 | NSLog(@"%d",outLength); 78 | }else { 79 | NSLog(@"no data"); 80 | } 81 | i += self.inputBytes; 82 | //判断是否结束 83 | if (i > pcmData.length - 1) { 84 | NSLog(@"读取数据结束"); 85 | break; 86 | } 87 | } 88 | //读取缓冲区数据 89 | while (1) { 90 | int outLength = faacEncEncode(self.encoder, NULL, 0, outputBuffer, self.maxOutputBytes); 91 | if (outLength > 0) { 92 | [temData appendBytes:outputBuffer length:outLength]; 93 | NSLog(@"%d",outLength); 94 | }else { 95 | break; 96 | } 97 | } 98 | 99 | return temData; 100 | } 101 | 102 | - (void)closeEncoder { 103 | faacEncClose(self.encoder); 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/ESCFAACDecoder.h: -------------------------------------------------------------------------------- 1 | // 2 | // ESCFAACDecoder.h 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #ifndef ESCFAACDecoder_h 10 | #define ESCFAACDecoder_h 11 | #import 12 | 13 | @interface ESCFAACDecoder : NSObject 14 | 15 | - (BOOL)setupDecoderWithSampleRate:(int)sampleRate channels:(int)channels bitRate:(int)bitRate; 16 | 17 | - (NSData *)decodeAACDataWithAACData:(NSData *)aacData; 18 | 19 | - (void)closeDecoder; 20 | 21 | @end 22 | 23 | 24 | #endif /* ESCFAACDecoder_h */ 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/ESCFAACDecoder.m: -------------------------------------------------------------------------------- 1 | // 2 | // ESCFAACDecoder.c 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #include "ESCFAACDecoder.h" 10 | #import "faad.h" 11 | 12 | //aac数据状态 13 | typedef enum { 14 | AccDataStatus_NotKnown = 0x00, //未知 15 | AccDataStatus_InValid = 0x01, //非法 16 | AccDataStatus_Valid = 0x02, //合法 17 | }fAccDataStatus; 18 | 19 | @interface ESCFAACDecoder () 20 | 21 | @property(nonatomic,assign)NeAACDecHandle decoder; 22 | 23 | @property(nonatomic,assign)NeAACDecFrameInfo frame_info; 24 | 25 | @property(nonatomic,assign)int sampleRate; 26 | 27 | @property(nonatomic,assign)int channels; 28 | 29 | @property(nonatomic,assign)int bitRate; 30 | 31 | @property(nonatomic,assign)int m_nFirstPackageAccDataStatus; 32 | 33 | @property(nonatomic,assign)BOOL m_bNeAACDecInit; 34 | 35 | @end 36 | 37 | 38 | @implementation ESCFAACDecoder 39 | 40 | - (BOOL)setupDecoderWithSampleRate:(int)sampleRate channels:(int)channels bitRate:(int)bitRate { 41 | 42 | NeAACDecHandle handle = NeAACDecOpen(); 43 | if(!handle){ 44 | printf("NeAACDecOpen failed\n"); 45 | return NO; 46 | } 47 | 48 | NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(handle); 49 | if(!conf){ 50 | printf("NeAACDecGetCurrentConfiguration failed\n"); 51 | if(handle){ 52 | NeAACDecClose(handle); 53 | } 54 | return NO; 55 | } 56 | conf->defObjectType = LC;//外加 57 | 58 | conf->defSampleRate = sampleRate; 59 | conf->outputFormat = FAAD_FMT_16BIT; 60 | conf->dontUpSampleImplicitSBR = 1; 61 | unsigned char setresult = NeAACDecSetConfiguration(handle, conf); 62 | if (setresult == 0) { 63 | printf("set configuration failed!\n"); 64 | if(handle){ 65 | NeAACDecClose(handle); 66 | } 67 | return NO; 68 | } 69 | 70 | self.decoder = handle; 71 | self.sampleRate = sampleRate; 72 | self.channels = channels; 73 | self.bitRate = bitRate; 74 | self.m_nFirstPackageAccDataStatus = AccDataStatus_NotKnown; 75 | self.m_bNeAACDecInit = NO; 76 | 77 | return YES; 78 | 79 | } 80 | 81 | - (NSData *)decodeAACDataWithAACData:(NSData *)aacData { 82 | 83 | unsigned char *pData = [aacData bytes]; 84 | int nLen = aacData.length; 85 | 86 | [self detectFirstPackageData:aacData]; 87 | if (self.m_nFirstPackageAccDataStatus != AccDataStatus_Valid) { 88 | printf("valid!\n"); 89 | return nil; 90 | } 91 | if (self.m_bNeAACDecInit == NO) { 92 | //initialize decoder 93 | unsigned long sample_rate = 0; 94 | unsigned long channels = 0; 95 | NeAACDecInit(self.decoder, pData, nLen, &sample_rate, &channels); 96 | printf("samplerate %ld, channels %ld\n", sample_rate, channels); 97 | self.m_bNeAACDecInit = YES; 98 | } 99 | 100 | int size = 0; 101 | unsigned char* pcm_data = NULL; 102 | NSMutableData *resultData = [NSMutableData data]; 103 | int total = 0; 104 | 105 | unsigned char frame[1024 * 15] = {0}; 106 | 107 | while ([ESCFAACDecoder getOneADTSFrame:pData buf_size:nLen frame:frame data_size:&size] == 0) { 108 | total += size; 109 | // NSData *temframe = [NSData dataWithBytes:frame length:size]; 110 | // NSLog(@"%@",temframe); 111 | printf("%d===frame size %d\n", total, size); 112 | //decode ADTS frame 113 | pcm_data = (unsigned char*)NeAACDecDecode(self.decoder, &_frame_info, frame, size); 114 | 115 | if(self.frame_info.error > 0) { 116 | printf("error == %s\n",NeAACDecGetErrorMessage(self.frame_info.error)); 117 | return resultData; 118 | }else if(pcm_data && self.frame_info.samples > 0){ 119 | printf("frame info: bytesconsumed %d, channels %d, header_type %d\ 120 | object_type %d, samples %d, samplerate %d\n", 121 | self.frame_info.bytesconsumed, 122 | self.frame_info.channels, self.frame_info.header_type, 123 | self.frame_info.object_type, self.frame_info.samples, 124 | self.frame_info.samplerate); 125 | 126 | unsigned int length; 127 | length = self.frame_info.samples * self.frame_info.channels; 128 | 129 | NSData *temPcmData = [NSData dataWithBytes:pcm_data length:length]; 130 | [resultData appendData:temPcmData]; 131 | } 132 | pData += size; 133 | nLen -= size; 134 | } 135 | 136 | return resultData; 137 | } 138 | 139 | - (void)closeDecoder { 140 | if(self.decoder == NULL){ 141 | return; 142 | } 143 | NeAACDecClose(self.decoder); 144 | } 145 | 146 | - (BOOL)detectFirstPackageData:(NSData *)aacData { 147 | int size = 0; 148 | unsigned char *bufferAAC = [aacData bytes]; 149 | 150 | unsigned char frame[1024 * 15] = {0}; 151 | if ([ESCFAACDecoder getOneADTSFrame:bufferAAC buf_size:aacData.length frame:frame data_size:&size] < 0) { 152 | self.m_nFirstPackageAccDataStatus = AccDataStatus_InValid; 153 | return NO; 154 | } 155 | self.m_nFirstPackageAccDataStatus = AccDataStatus_Valid; 156 | return YES; 157 | } 158 | 159 | + (int)getOneADTSFrame:(unsigned char *)buffer buf_size:(int)buf_size frame:(unsigned char *)data data_size:(int *)data_size { 160 | int size = 0; 161 | 162 | if(!buffer || !data || !data_size ) { 163 | return -1; 164 | } 165 | 166 | while(1){ 167 | if(buf_size < 7 ) { 168 | return -1; 169 | } 170 | 171 | if ((buffer[0] == 0xff) && ((buffer[1] & 0xf0) == 0xf0)) 172 | { 173 | // profile; 2 uimsbf 174 | // sampling_frequency_index; 4 uimsbf 175 | // private_bit; 1 bslbf 176 | // channel_configuration; 3 uimsbf 177 | // original/copy; 1 bslbf 178 | // home; 1 bslbf 179 | // copyright_identification_bit; 1 bslbf 180 | // copyright_identification_start; 1 bslbf 181 | // frame_length; 13 bslbf 182 | 183 | int size_1 = buffer[3] & 0x03; 184 | int size_2 = buffer[4]; 185 | int size_3 = buffer[5] & 0xe0; 186 | 187 | // NSLog(@"%d==%d=%d=%d",buffer[3],size_1,size_2,size_3); 188 | 189 | size = size | (size_1 << 11); 190 | size = size | (size_2 << 3); 191 | size = size | (size_3 >> 5); 192 | 193 | // size |= (((buffer[3] & 0x03)) << 11);//high 2 bit 194 | // size |= (buffer[4] << 3);//middle 8 bit 195 | // size |= ((buffer[5] & 0xe0) >> 5);//low 3bit 196 | 197 | // printf("len1=%x\n", (buffer[3] & 0x03)); 198 | // printf("len2=%x\n", buffer[4]); 199 | // printf("len3=%x\n", (buffer[5] & 0xe0) >> 5); 200 | // printf("size=%d\r\n", (int)size); 201 | 202 | // int8_t fullness = 0; 203 | // 204 | // fullness |= buffer[5] & 0x1f << 6; 205 | // fullness |= buffer[6] & 0xfc >> 2; 206 | // NSLog(@"%d==%d",fullness,size); 207 | 208 | break; 209 | } 210 | --buf_size; 211 | ++buffer; 212 | } 213 | 214 | if(buf_size < size) 215 | { 216 | return -1; 217 | } 218 | 219 | memcpy(data, buffer, size); 220 | *data_size = size; 221 | 222 | return 0; 223 | } 224 | 225 | @end 226 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "faac/include/faac.h" 11 | #import "ESCFAACDecoder.h" 12 | #import "ESCAACEncoder.h" 13 | 14 | 15 | typedef unsigned long ULONG; 16 | typedef unsigned int UINT; 17 | typedef unsigned char BYTE; 18 | typedef char _TCHAR; 19 | 20 | @interface ViewController () 21 | 22 | @end 23 | 24 | @implementation ViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | // Do any additional setup after loading the view, typically from a nib. 29 | 30 | [self PCMToAAC]; 31 | 32 | [self PCMToAAC2]; 33 | 34 | [self AACToPCM]; 35 | 36 | [self AACToPCM2]; 37 | } 38 | 39 | - (void)PCMToAAC2 { 40 | ESCAACEncoder *aacEncoder = [[ESCAACEncoder alloc] init]; 41 | [aacEncoder setupEncoderWithSampleRate:8000 channels:1 sampleBit:16]; 42 | 43 | NSString *pcmPath = [[NSBundle mainBundle] pathForResource:@"8000_16_1_1.pcm" ofType:nil]; 44 | 45 | NSString *cachesPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject; 46 | NSString *aacPath = [NSString stringWithFormat:@"%@/8000_16_1_1.aac",cachesPath]; 47 | 48 | NSData *pcmData = [NSData dataWithContentsOfFile:pcmPath]; 49 | NSData *aacData = [aacEncoder encodePCMDataWithPCMData:pcmData]; 50 | 51 | if (aacData.length > 0) { 52 | [aacData writeToFile:aacPath atomically:YES]; 53 | } 54 | [aacEncoder closeEncoder]; 55 | 56 | } 57 | 58 | - (void)PCMToAAC { 59 | 60 | ESCAACEncoder *aacEncoder = [[ESCAACEncoder alloc] init]; 61 | [aacEncoder setupEncoderWithSampleRate:44100 channels:2 sampleBit:16]; 62 | 63 | NSString *pcmPath = [[NSBundle mainBundle] pathForResource:@"vocal.pcm" ofType:nil]; 64 | 65 | NSString *cachesPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject; 66 | NSString *aacPath = [NSString stringWithFormat:@"%@/vocal.aac",cachesPath]; 67 | 68 | NSData *pcmData = [NSData dataWithContentsOfFile:pcmPath]; 69 | NSData *aacData = [aacEncoder encodePCMDataWithPCMData:pcmData]; 70 | 71 | if (aacData.length > 0) { 72 | [aacData writeToFile:aacPath atomically:YES]; 73 | } 74 | [aacEncoder closeEncoder]; 75 | } 76 | 77 | - (void)AACToPCM { 78 | 79 | ESCFAACDecoder *aacDecoder = [[ESCFAACDecoder alloc] init]; 80 | [aacDecoder setupDecoderWithSampleRate:44100 channels:2 bitRate:20480]; 81 | 82 | NSString *aacPath = [[NSBundle mainBundle] pathForResource:@"vocal.aac" ofType:nil]; 83 | NSString *cachesPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject; 84 | NSString *pcmPath = [NSString stringWithFormat:@"%@/vocal.pcm",cachesPath]; 85 | 86 | 87 | NSData *aacData = [NSData dataWithContentsOfFile:aacPath]; 88 | if (aacData == nil || aacData.length <= 0) { 89 | [aacDecoder closeDecoder]; 90 | NSLog(@"读取数据失败"); 91 | return; 92 | } 93 | 94 | NSData *pcmdata = [aacDecoder decodeAACDataWithAACData:aacData]; 95 | [aacDecoder closeDecoder]; 96 | 97 | if (pcmdata.length > 0) { 98 | [pcmdata writeToFile:pcmPath atomically:YES]; 99 | }else{ 100 | NSLog(@"aac to pcm failed!"); 101 | } 102 | } 103 | 104 | - (void)AACToPCM2 { 105 | 106 | ESCFAACDecoder *aacDecoder = [[ESCFAACDecoder alloc] init]; 107 | [aacDecoder setupDecoderWithSampleRate:8000 channels:1 bitRate:20480]; 108 | 109 | NSString *aacPath = [[NSBundle mainBundle] pathForResource:@"8000_16_1.aac" ofType:nil]; 110 | NSString *cachesPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).lastObject; 111 | NSString *pcmPath = [NSString stringWithFormat:@"%@/8000_16_1.pcm",cachesPath]; 112 | 113 | NSData *aacData = [NSData dataWithContentsOfFile:aacPath]; 114 | if (aacData == nil || aacData.length <= 0) { 115 | [aacDecoder closeDecoder]; 116 | NSLog(@"读取数据失败"); 117 | return; 118 | } 119 | NSData *pcmdata = [aacDecoder decodeAACDataWithAACData:aacData]; 120 | [aacDecoder closeDecoder]; 121 | if (pcmdata.length > 0) { 122 | [pcmdata writeToFile:pcmPath atomically:YES]; 123 | }else{ 124 | NSLog(@"aac to pcm failed!"); 125 | } 126 | } 127 | 128 | @end 129 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faac/include/faac.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FAAC - Freeware Advanced Audio Coder 3 | * Copyright (C) 2001 Menno Bakker 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: faac.h,v 1.38 2012/03/01 18:34:17 knik Exp $ 20 | */ 21 | 22 | #ifndef _FAAC_H_ 23 | #define _FAAC_H_ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif /* __cplusplus */ 28 | 29 | 30 | #if !defined(FAACAPI) && defined(__GNUC__) && (__GNUC__ >= 4) 31 | # if defined(_WIN32) 32 | # define FAACAPI __stdcall __declspec(dllexport) 33 | # else 34 | # define FAACAPI __attribute__((visibility("default"))) 35 | # endif 36 | #endif 37 | #ifndef FAACAPI 38 | # define FAACAPI 39 | #endif 40 | 41 | #pragma pack(push, 1) 42 | 43 | typedef struct { 44 | void *ptr; 45 | char *name; 46 | } 47 | psymodellist_t; 48 | 49 | #include "faaccfg.h" 50 | 51 | 52 | typedef void *faacEncHandle; 53 | 54 | #ifndef HAVE_INT32_T 55 | typedef signed int int32_t; 56 | #endif 57 | 58 | /* 59 | Allows an application to get FAAC version info. This is intended 60 | purely for informative purposes. 61 | 62 | Returns FAAC_CFG_VERSION. 63 | */ 64 | int FAACAPI faacEncGetVersion(char **faac_id_string, 65 | char **faac_copyright_string); 66 | 67 | 68 | faacEncConfigurationPtr FAACAPI 69 | faacEncGetCurrentConfiguration(faacEncHandle hEncoder); 70 | 71 | 72 | int FAACAPI faacEncSetConfiguration(faacEncHandle hEncoder, 73 | faacEncConfigurationPtr config); 74 | 75 | 76 | faacEncHandle FAACAPI faacEncOpen(unsigned long sampleRate, 77 | unsigned int numChannels, 78 | unsigned long *inputSamples, 79 | unsigned long *maxOutputBytes 80 | ); 81 | 82 | int FAACAPI faacEncGetDecoderSpecificInfo(faacEncHandle hEncoder, unsigned char **ppBuffer, 83 | unsigned long *pSizeOfDecoderSpecificInfo); 84 | 85 | 86 | int FAACAPI faacEncEncode(faacEncHandle hEncoder, int32_t * inputBuffer, unsigned int samplesInput, 87 | unsigned char *outputBuffer, 88 | unsigned int bufferSize); 89 | 90 | 91 | int FAACAPI faacEncClose(faacEncHandle hEncoder); 92 | 93 | 94 | 95 | #pragma pack(pop) 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif /* __cplusplus */ 100 | 101 | #endif /* _FAAC_H_ */ 102 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faac/include/faaccfg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FAAC - Freeware Advanced Audio Coder 3 | * Copyright (C) 2001 Menno Bakker 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | * $Id: faaccfg.h,v 1.3 2004/07/04 12:12:05 corrados Exp $ 20 | */ 21 | 22 | #ifndef _FAACCFG_H_ 23 | #define _FAACCFG_H_ 24 | 25 | #define FAAC_CFG_VERSION 105 26 | 27 | /* MPEG ID's */ 28 | #define MPEG2 1 29 | #define MPEG4 0 30 | 31 | /* AAC object types */ 32 | #define MAIN 1 33 | #define LOW 2 34 | #define SSR 3 35 | #define LTP 4 36 | 37 | /* Input Formats */ 38 | #define FAAC_INPUT_NULL 0 39 | #define FAAC_INPUT_16BIT 1 40 | #define FAAC_INPUT_24BIT 2 41 | #define FAAC_INPUT_32BIT 3 42 | #define FAAC_INPUT_FLOAT 4 43 | 44 | #define SHORTCTL_NORMAL 0 45 | #define SHORTCTL_NOSHORT 1 46 | #define SHORTCTL_NOLONG 2 47 | 48 | enum stream_format 49 | { 50 | RAW_STREAM = 0, 51 | ADTS_STREAM = 1, 52 | }; 53 | 54 | enum {JOINT_NONE = 0, JOINT_MS, JOINT_IS}; 55 | 56 | #pragma pack(push, 1) 57 | typedef struct faacEncConfiguration 58 | { 59 | /* config version */ 60 | int version; 61 | 62 | /* library version */ 63 | char *name; 64 | 65 | /* copyright string */ 66 | char *copyright; 67 | 68 | /* MPEG version, 2 or 4 */ 69 | unsigned int mpegVersion; 70 | 71 | /* AAC object type */ 72 | unsigned int aacObjectType; 73 | 74 | union { 75 | /* Joint coding mode */ 76 | unsigned int jointmode; 77 | /* compatibility alias */ 78 | unsigned int allowMidside; 79 | }; 80 | 81 | /* Use one of the channels as LFE channel */ 82 | unsigned int useLfe; 83 | 84 | /* Use Temporal Noise Shaping */ 85 | unsigned int useTns; 86 | 87 | /* bitrate / channel of AAC file */ 88 | unsigned long bitRate; 89 | 90 | /* AAC file frequency bandwidth */ 91 | unsigned int bandWidth; 92 | 93 | /* Quantizer quality */ 94 | unsigned long quantqual; 95 | 96 | /* Bitstream output format (0 = Raw; 1 = ADTS) */ 97 | unsigned int outputFormat; 98 | 99 | /* psychoacoustic model list */ 100 | psymodellist_t *psymodellist; 101 | 102 | /* selected index in psymodellist */ 103 | unsigned int psymodelidx; 104 | 105 | /* 106 | PCM Sample Input Format 107 | 0 FAAC_INPUT_NULL invalid, signifies a misconfigured config 108 | 1 FAAC_INPUT_16BIT native endian 16bit 109 | 2 FAAC_INPUT_24BIT native endian 24bit in 24 bits (not implemented) 110 | 3 FAAC_INPUT_32BIT native endian 24bit in 32 bits (DEFAULT) 111 | 4 FAAC_INPUT_FLOAT 32bit floating point 112 | */ 113 | unsigned int inputFormat; 114 | 115 | /* block type enforcing (SHORTCTL_NORMAL/SHORTCTL_NOSHORT/SHORTCTL_NOLONG) */ 116 | int shortctl; 117 | 118 | /* 119 | Channel Remapping 120 | 121 | Default 0, 1, 2, 3 ... 63 (64 is MAX_CHANNELS in coder.h) 122 | 123 | WAVE 4.0 2, 0, 1, 3 124 | WAVE 5.0 2, 0, 1, 3, 4 125 | WAVE 5.1 2, 0, 1, 4, 5, 3 126 | AIFF 5.1 2, 0, 3, 1, 4, 5 127 | */ 128 | int channel_map[64]; 129 | int pnslevel; 130 | } faacEncConfiguration, *faacEncConfigurationPtr; 131 | 132 | #pragma pack(pop) 133 | 134 | #endif /* _FAACCFG_H_ */ 135 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faac/lib/libfaac.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo/faac/lib/libfaac.a -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faad/include/faad.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: faad.h,v 1.51 2007/11/01 12:33:29 menno Exp $ 29 | **/ 30 | 31 | /* warn people for update */ 32 | #pragma message("please update faad2 include filename and function names!") 33 | 34 | /* Backwards compatible link */ 35 | #include "neaacdec.h" 36 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faad/include/mp4ff.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: mp4ff.h,v 1.27 2009/01/29 00:41:08 menno Exp $ 29 | **/ 30 | 31 | #ifndef MP4FF_H 32 | #define MP4FF_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif /* __cplusplus */ 37 | 38 | #ifdef HAVE_STDINT_H 39 | #include 40 | #else 41 | #include "mp4ff_int_types.h" 42 | #endif 43 | 44 | /* file callback structure */ 45 | typedef struct 46 | { 47 | uint32_t (*read)(void *user_data, void *buffer, uint32_t length); 48 | uint32_t (*write)(void *udata, void *buffer, uint32_t length); 49 | uint32_t (*seek)(void *user_data, uint64_t position); 50 | uint32_t (*truncate)(void *user_data); 51 | void *user_data; 52 | } mp4ff_callback_t; 53 | 54 | /* mp4 main file structure */ 55 | typedef void* mp4ff_t; 56 | 57 | 58 | /* API */ 59 | 60 | mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f); 61 | mp4ff_t *mp4ff_open_read_metaonly(mp4ff_callback_t *f); 62 | void mp4ff_close(mp4ff_t *f); 63 | int32_t mp4ff_get_sample_duration(const mp4ff_t *f, const int32_t track, const int32_t sample); 64 | int32_t mp4ff_get_sample_duration_use_offsets(const mp4ff_t *f, const int32_t track, const int32_t sample); 65 | int64_t mp4ff_get_sample_position(const mp4ff_t *f, const int32_t track, const int32_t sample); 66 | int32_t mp4ff_get_sample_offset(const mp4ff_t *f, const int32_t track, const int32_t sample); 67 | int32_t mp4ff_find_sample(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip); 68 | int32_t mp4ff_find_sample_use_offsets(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip); 69 | 70 | int32_t mp4ff_read_sample(mp4ff_t *f, const int track, const int sample, 71 | unsigned char **audio_buffer, unsigned int *bytes); 72 | 73 | int32_t mp4ff_read_sample_v2(mp4ff_t *f, const int track, const int sample,unsigned char *buffer);//returns 0 on error, number of bytes read on success, use mp4ff_read_sample_getsize() to check buffer size needed 74 | int32_t mp4ff_read_sample_getsize(mp4ff_t *f, const int track, const int sample);//returns 0 on error, buffer size needed for mp4ff_read_sample_v2() on success 75 | 76 | 77 | 78 | int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int track, 79 | unsigned char** ppBuf, unsigned int* pBufSize); 80 | int32_t mp4ff_get_track_type(const mp4ff_t *f, const int track); 81 | int32_t mp4ff_total_tracks(const mp4ff_t *f); 82 | int32_t mp4ff_num_samples(const mp4ff_t *f, const int track); 83 | int32_t mp4ff_time_scale(const mp4ff_t *f, const int track); 84 | 85 | uint32_t mp4ff_get_avg_bitrate(const mp4ff_t *f, const int32_t track); 86 | uint32_t mp4ff_get_max_bitrate(const mp4ff_t *f, const int32_t track); 87 | int64_t mp4ff_get_track_duration(const mp4ff_t *f, const int32_t track); //returns (-1) if unknown 88 | int64_t mp4ff_get_track_duration_use_offsets(const mp4ff_t *f, const int32_t track); //returns (-1) if unknown 89 | uint32_t mp4ff_get_sample_rate(const mp4ff_t *f, const int32_t track); 90 | uint32_t mp4ff_get_channel_count(const mp4ff_t * f,const int32_t track); 91 | uint32_t mp4ff_get_audio_type(const mp4ff_t * f,const int32_t track); 92 | 93 | 94 | /* metadata */ 95 | int mp4ff_meta_get_num_items(const mp4ff_t *f); 96 | int mp4ff_meta_get_by_index(const mp4ff_t *f, unsigned int index, 97 | char **item, char **value); 98 | int mp4ff_meta_get_title(const mp4ff_t *f, char **value); 99 | int mp4ff_meta_get_artist(const mp4ff_t *f, char **value); 100 | int mp4ff_meta_get_writer(const mp4ff_t *f, char **value); 101 | int mp4ff_meta_get_album(const mp4ff_t *f, char **value); 102 | int mp4ff_meta_get_date(const mp4ff_t *f, char **value); 103 | int mp4ff_meta_get_tool(const mp4ff_t *f, char **value); 104 | int mp4ff_meta_get_comment(const mp4ff_t *f, char **value); 105 | int mp4ff_meta_get_genre(const mp4ff_t *f, char **value); 106 | int mp4ff_meta_get_track(const mp4ff_t *f, char **value); 107 | int mp4ff_meta_get_disc(const mp4ff_t *f, char **value); 108 | int mp4ff_meta_get_totaltracks(const mp4ff_t *f, char **value); 109 | int mp4ff_meta_get_totaldiscs(const mp4ff_t *f, char **value); 110 | int mp4ff_meta_get_compilation(const mp4ff_t *f, char **value); 111 | int mp4ff_meta_get_tempo(const mp4ff_t *f, char **value); 112 | int32_t mp4ff_meta_get_coverart(const mp4ff_t *f, char **value); 113 | #ifdef USE_TAGGING 114 | 115 | /* metadata tag structure */ 116 | typedef struct 117 | { 118 | char *item; 119 | char *value; 120 | } mp4ff_tag_t; 121 | 122 | /* metadata list structure */ 123 | typedef struct 124 | { 125 | mp4ff_tag_t *tags; 126 | uint32_t count; 127 | } mp4ff_metadata_t; 128 | 129 | int32_t mp4ff_meta_update(mp4ff_callback_t *f,const mp4ff_metadata_t * data); 130 | 131 | #endif 132 | 133 | 134 | #ifdef __cplusplus 135 | } 136 | #endif /* __cplusplus */ 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faad/include/mp4ffint.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: mp4ffint.h,v 1.26 2009/01/25 20:14:34 menno Exp $ 29 | **/ 30 | 31 | #ifndef MP4FF_INTERNAL_H 32 | #define MP4FF_INTERNAL_H 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif /* __cplusplus */ 37 | 38 | #include "mp4ff_int_types.h" 39 | #include 40 | 41 | #define MAX_TRACKS 1024 42 | #define TRACK_UNKNOWN 0 43 | #define TRACK_AUDIO 1 44 | #define TRACK_VIDEO 2 45 | #define TRACK_SYSTEM 3 46 | 47 | 48 | #define SUBATOMIC 128 49 | 50 | /* atoms without subatoms */ 51 | #define ATOM_FTYP 129 52 | #define ATOM_MDAT 130 53 | #define ATOM_MVHD 131 54 | #define ATOM_TKHD 132 55 | #define ATOM_TREF 133 56 | #define ATOM_MDHD 134 57 | #define ATOM_VMHD 135 58 | #define ATOM_SMHD 136 59 | #define ATOM_HMHD 137 60 | #define ATOM_STSD 138 61 | #define ATOM_STTS 139 62 | #define ATOM_STSZ 140 63 | #define ATOM_STZ2 141 64 | #define ATOM_STCO 142 65 | #define ATOM_STSC 143 66 | #define ATOM_MP4A 144 67 | #define ATOM_MP4V 145 68 | #define ATOM_MP4S 146 69 | #define ATOM_ESDS 147 70 | #define ATOM_META 148 /* iTunes Metadata box */ 71 | #define ATOM_NAME 149 /* iTunes Metadata name box */ 72 | #define ATOM_DATA 150 /* iTunes Metadata data box */ 73 | #define ATOM_CTTS 151 74 | #define ATOM_FRMA 152 75 | #define ATOM_IVIV 153 76 | #define ATOM_PRIV 154 77 | #define ATOM_USER 155 78 | #define ATOM_KEY 156 79 | 80 | #define ATOM_ALBUM_ARTIST 157 81 | #define ATOM_CONTENTGROUP 158 82 | #define ATOM_LYRICS 159 83 | #define ATOM_DESCRIPTION 160 84 | #define ATOM_NETWORK 161 85 | #define ATOM_SHOW 162 86 | #define ATOM_EPISODENAME 163 87 | #define ATOM_SORTTITLE 164 88 | #define ATOM_SORTALBUM 165 89 | #define ATOM_SORTARTIST 166 90 | #define ATOM_SORTALBUMARTIST 167 91 | #define ATOM_SORTWRITER 168 92 | #define ATOM_SORTSHOW 169 93 | #define ATOM_SEASON 170 94 | #define ATOM_EPISODE 171 95 | #define ATOM_PODCAST 172 96 | 97 | #define ATOM_UNKNOWN 255 98 | #define ATOM_FREE ATOM_UNKNOWN 99 | #define ATOM_SKIP ATOM_UNKNOWN 100 | 101 | /* atoms with subatoms */ 102 | #define ATOM_MOOV 1 103 | #define ATOM_TRAK 2 104 | #define ATOM_EDTS 3 105 | #define ATOM_MDIA 4 106 | #define ATOM_MINF 5 107 | #define ATOM_STBL 6 108 | #define ATOM_UDTA 7 109 | #define ATOM_ILST 8 /* iTunes Metadata list */ 110 | #define ATOM_TITLE 9 111 | #define ATOM_ARTIST 10 112 | #define ATOM_WRITER 11 113 | #define ATOM_ALBUM 12 114 | #define ATOM_DATE 13 115 | #define ATOM_TOOL 14 116 | #define ATOM_COMMENT 15 117 | #define ATOM_GENRE1 16 118 | #define ATOM_TRACK 17 119 | #define ATOM_DISC 18 120 | #define ATOM_COMPILATION 19 121 | #define ATOM_GENRE2 20 122 | #define ATOM_TEMPO 21 123 | #define ATOM_COVER 22 124 | #define ATOM_DRMS 23 125 | #define ATOM_SINF 24 126 | #define ATOM_SCHI 25 127 | 128 | #ifdef HAVE_CONFIG_H 129 | #include "../../config.h" 130 | #endif 131 | 132 | #if !(defined(_WIN32) || defined(_WIN32_WCE)) 133 | #define stricmp strcasecmp 134 | #else 135 | #define stricmp _stricmp 136 | #define strdup _strdup 137 | #endif 138 | 139 | /* file callback structure */ 140 | typedef struct 141 | { 142 | uint32_t (*read)(void *user_data, void *buffer, uint32_t length); 143 | uint32_t (*write)(void *udata, void *buffer, uint32_t length); 144 | uint32_t (*seek)(void *user_data, uint64_t position); 145 | uint32_t (*truncate)(void *user_data); 146 | void *user_data; 147 | } mp4ff_callback_t; 148 | 149 | 150 | /* metadata tag structure */ 151 | typedef struct 152 | { 153 | char *item; 154 | char *value; 155 | } mp4ff_tag_t; 156 | 157 | /* metadata list structure */ 158 | typedef struct 159 | { 160 | mp4ff_tag_t *tags; 161 | uint32_t count; 162 | } mp4ff_metadata_t; 163 | 164 | 165 | typedef struct 166 | { 167 | int32_t type; 168 | int32_t channelCount; 169 | int32_t sampleSize; 170 | uint16_t sampleRate; 171 | int32_t audioType; 172 | 173 | /* stsd */ 174 | int32_t stsd_entry_count; 175 | 176 | /* stsz */ 177 | int32_t stsz_sample_size; 178 | int32_t stsz_sample_count; 179 | int32_t *stsz_table; 180 | 181 | /* stts */ 182 | int32_t stts_entry_count; 183 | int32_t *stts_sample_count; 184 | int32_t *stts_sample_delta; 185 | 186 | /* stsc */ 187 | int32_t stsc_entry_count; 188 | int32_t *stsc_first_chunk; 189 | int32_t *stsc_samples_per_chunk; 190 | int32_t *stsc_sample_desc_index; 191 | 192 | /* stsc */ 193 | int32_t stco_entry_count; 194 | int32_t *stco_chunk_offset; 195 | 196 | /* ctts */ 197 | int32_t ctts_entry_count; 198 | int32_t *ctts_sample_count; 199 | int32_t *ctts_sample_offset; 200 | 201 | /* esde */ 202 | uint8_t *decoderConfig; 203 | int32_t decoderConfigLen; 204 | 205 | uint32_t maxBitrate; 206 | uint32_t avgBitrate; 207 | 208 | uint32_t timeScale; 209 | uint64_t duration; 210 | 211 | } mp4ff_track_t; 212 | 213 | /* mp4 main file structure */ 214 | typedef struct 215 | { 216 | /* stream to read from */ 217 | mp4ff_callback_t *stream; 218 | int64_t current_position; 219 | 220 | int32_t moov_read; 221 | uint64_t moov_offset; 222 | uint64_t moov_size; 223 | uint8_t last_atom; 224 | uint64_t file_size; 225 | 226 | /* mvhd */ 227 | int32_t time_scale; 228 | int32_t duration; 229 | 230 | /* incremental track index while reading the file */ 231 | int32_t total_tracks; 232 | 233 | /* track data */ 234 | mp4ff_track_t *track[MAX_TRACKS]; 235 | 236 | /* metadata */ 237 | mp4ff_metadata_t tags; 238 | } mp4ff_t; 239 | 240 | 241 | 242 | 243 | /* mp4util.c */ 244 | int32_t mp4ff_read_data(mp4ff_t *f, int8_t *data, uint32_t size); 245 | int32_t mp4ff_write_data(mp4ff_t *f, int8_t *data, uint32_t size); 246 | uint64_t mp4ff_read_int64(mp4ff_t *f); 247 | uint32_t mp4ff_read_int32(mp4ff_t *f); 248 | uint32_t mp4ff_read_int24(mp4ff_t *f); 249 | uint16_t mp4ff_read_int16(mp4ff_t *f); 250 | uint8_t mp4ff_read_char(mp4ff_t *f); 251 | int32_t mp4ff_write_int32(mp4ff_t *f,const uint32_t data); 252 | uint32_t mp4ff_read_mp4_descr_length(mp4ff_t *f); 253 | int64_t mp4ff_position(const mp4ff_t *f); 254 | int32_t mp4ff_set_position(mp4ff_t *f, const int64_t position); 255 | int32_t mp4ff_truncate(mp4ff_t * f); 256 | char * mp4ff_read_string(mp4ff_t * f,uint32_t length); 257 | 258 | /* mp4atom.c */ 259 | static int32_t mp4ff_atom_get_size(const int8_t *data); 260 | static int32_t mp4ff_atom_compare(const int8_t a1, const int8_t b1, const int8_t c1, const int8_t d1, 261 | const int8_t a2, const int8_t b2, const int8_t c2, const int8_t d2); 262 | static uint8_t mp4ff_atom_name_to_type(const int8_t a, const int8_t b, const int8_t c, const int8_t d); 263 | uint64_t mp4ff_atom_read_header(mp4ff_t *f, uint8_t *atom_type, uint8_t *header_size); 264 | static int32_t mp4ff_read_stsz(mp4ff_t *f); 265 | static int32_t mp4ff_read_esds(mp4ff_t *f); 266 | static int32_t mp4ff_read_mp4a(mp4ff_t *f); 267 | static int32_t mp4ff_read_stsd(mp4ff_t *f); 268 | static int32_t mp4ff_read_stsc(mp4ff_t *f); 269 | static int32_t mp4ff_read_stco(mp4ff_t *f); 270 | static int32_t mp4ff_read_stts(mp4ff_t *f); 271 | #ifdef USE_TAGGING 272 | static int32_t mp4ff_read_meta(mp4ff_t *f, const uint64_t size); 273 | #endif 274 | int32_t mp4ff_atom_read(mp4ff_t *f, const int32_t size, const uint8_t atom_type); 275 | 276 | /* mp4sample.c */ 277 | static int32_t mp4ff_chunk_of_sample(const mp4ff_t *f, const int32_t track, const int32_t sample, 278 | int32_t *chunk_sample, int32_t *chunk); 279 | static int32_t mp4ff_chunk_to_offset(const mp4ff_t *f, const int32_t track, const int32_t chunk); 280 | static int32_t mp4ff_sample_range_size(const mp4ff_t *f, const int32_t track, 281 | const int32_t chunk_sample, const int32_t sample); 282 | static int32_t mp4ff_sample_to_offset(const mp4ff_t *f, const int32_t track, const int32_t sample); 283 | int32_t mp4ff_audio_frame_size(const mp4ff_t *f, const int32_t track, const int32_t sample); 284 | int32_t mp4ff_set_sample_position(mp4ff_t *f, const int32_t track, const int32_t sample); 285 | 286 | #ifdef USE_TAGGING 287 | /* mp4meta.c */ 288 | static int32_t mp4ff_tag_add_field(mp4ff_metadata_t *tags, const char *item, const char *value); 289 | static int32_t mp4ff_tag_set_field(mp4ff_metadata_t *tags, const char *item, const char *value); 290 | static int32_t mp4ff_set_metadata_name(mp4ff_t *f, const uint8_t atom_type, char **name); 291 | static int32_t mp4ff_parse_tag(mp4ff_t *f, const uint8_t parent_atom_type, const int32_t size); 292 | static int32_t mp4ff_meta_find_by_name(const mp4ff_t *f, const char *item, char **value); 293 | int32_t mp4ff_parse_metadata(mp4ff_t *f, const int32_t size); 294 | int32_t mp4ff_tag_delete(mp4ff_metadata_t *tags); 295 | int32_t mp4ff_meta_get_num_items(const mp4ff_t *f); 296 | int32_t mp4ff_meta_get_by_index(const mp4ff_t *f, uint32_t index, 297 | char **item, char **value); 298 | int32_t mp4ff_meta_get_title(const mp4ff_t *f, char **value); 299 | int32_t mp4ff_meta_get_artist(const mp4ff_t *f, char **value); 300 | int32_t mp4ff_meta_get_writer(const mp4ff_t *f, char **value); 301 | int32_t mp4ff_meta_get_album(const mp4ff_t *f, char **value); 302 | int32_t mp4ff_meta_get_date(const mp4ff_t *f, char **value); 303 | int32_t mp4ff_meta_get_tool(const mp4ff_t *f, char **value); 304 | int32_t mp4ff_meta_get_comment(const mp4ff_t *f, char **value); 305 | int32_t mp4ff_meta_get_genre(const mp4ff_t *f, char **value); 306 | int32_t mp4ff_meta_get_track(const mp4ff_t *f, char **value); 307 | int32_t mp4ff_meta_get_disc(const mp4ff_t *f, char **value); 308 | int32_t mp4ff_meta_get_compilation(const mp4ff_t *f, char **value); 309 | int32_t mp4ff_meta_get_tempo(const mp4ff_t *f, char **value); 310 | int32_t mp4ff_meta_get_coverart(const mp4ff_t *f, char **value); 311 | #endif 312 | 313 | /* mp4ff.c */ 314 | mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f); 315 | #ifdef USE_TAGGING 316 | mp4ff_t *mp4ff_open_edit(mp4ff_callback_t *f); 317 | #endif 318 | void mp4ff_close(mp4ff_t *ff); 319 | //void mp4ff_track_add(mp4ff_t *f); 320 | int32_t parse_sub_atoms(mp4ff_t *f, const uint64_t total_size,int meta_only); 321 | int32_t parse_atoms(mp4ff_t *f,int meta_only); 322 | 323 | int32_t mp4ff_get_sample_duration(const mp4ff_t *f, const int32_t track, const int32_t sample); 324 | int64_t mp4ff_get_sample_position(const mp4ff_t *f, const int32_t track, const int32_t sample); 325 | int32_t mp4ff_get_sample_offset(const mp4ff_t *f, const int32_t track, const int32_t sample); 326 | int32_t mp4ff_find_sample(const mp4ff_t *f, const int32_t track, const int64_t offset,int32_t * toskip); 327 | 328 | int32_t mp4ff_read_sample(mp4ff_t *f, const int32_t track, const int32_t sample, 329 | uint8_t **audio_buffer, uint32_t *bytes); 330 | int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int32_t track, 331 | uint8_t** ppBuf, uint32_t* pBufSize); 332 | int32_t mp4ff_total_tracks(const mp4ff_t *f); 333 | int32_t mp4ff_time_scale(const mp4ff_t *f, const int32_t track); 334 | int32_t mp4ff_num_samples(const mp4ff_t *f, const int32_t track); 335 | 336 | uint32_t mp4ff_meta_genre_to_index(const char * genrestr);//returns 1-based index, 0 if not found 337 | const char * mp4ff_meta_index_to_genre(uint32_t idx);//returns pointer to static string 338 | 339 | 340 | #ifdef __cplusplus 341 | } 342 | #endif /* __cplusplus */ 343 | 344 | #endif 345 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faad/include/neaacdec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 4 | ** 5 | ** This program is free software; you can redistribute it and/or modify 6 | ** it under the terms of the GNU General Public License as published by 7 | ** the Free Software Foundation; either version 2 of the License, or 8 | ** (at your option) any later version. 9 | ** 10 | ** This program is distributed in the hope that it will be useful, 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ** GNU General Public License for more details. 14 | ** 15 | ** You should have received a copy of the GNU General Public License 16 | ** along with this program; if not, write to the Free Software 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 | ** 19 | ** Any non-GPL usage of this software or parts of this software is strictly 20 | ** forbidden. 21 | ** 22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" 24 | ** 25 | ** Commercial non-GPL licensing of this software is possible. 26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. 27 | ** 28 | ** $Id: neaacdec.h,v 1.13 2009/01/26 23:51:15 menno Exp $ 29 | **/ 30 | 31 | #ifndef __NEAACDEC_H__ 32 | #define __NEAACDEC_H__ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif /* __cplusplus */ 37 | 38 | 39 | #if 1 40 | /* MACROS FOR BACKWARDS COMPATIBILITY */ 41 | /* structs */ 42 | #define faacDecHandle NeAACDecHandle 43 | #define faacDecConfiguration NeAACDecConfiguration 44 | #define faacDecConfigurationPtr NeAACDecConfigurationPtr 45 | #define faacDecFrameInfo NeAACDecFrameInfo 46 | /* functions */ 47 | #define faacDecGetErrorMessage NeAACDecGetErrorMessage 48 | #define faacDecSetConfiguration NeAACDecSetConfiguration 49 | #define faacDecGetCurrentConfiguration NeAACDecGetCurrentConfiguration 50 | #define faacDecInit NeAACDecInit 51 | #define faacDecInit2 NeAACDecInit2 52 | #define faacDecInitDRM NeAACDecInitDRM 53 | #define faacDecPostSeekReset NeAACDecPostSeekReset 54 | #define faacDecOpen NeAACDecOpen 55 | #define faacDecClose NeAACDecClose 56 | #define faacDecDecode NeAACDecDecode 57 | #define AudioSpecificConfig NeAACDecAudioSpecificConfig 58 | #endif 59 | 60 | 61 | #ifdef _WIN32 62 | #pragma pack(push, 8) 63 | #ifndef NEAACDECAPI 64 | #define NEAACDECAPI __cdecl 65 | #endif 66 | #else 67 | #ifndef NEAACDECAPI 68 | #define NEAACDECAPI 69 | #endif 70 | #endif 71 | 72 | #define FAAD2_VERSION "2.7" 73 | 74 | /* object types for AAC */ 75 | #define MAIN 1 76 | #define LC 2 77 | #define SSR 3 78 | #define LTP 4 79 | #define HE_AAC 5 80 | #define ER_LC 17 81 | #define ER_LTP 19 82 | #define LD 23 83 | #define DRM_ER_LC 27 /* special object type for DRM */ 84 | 85 | /* header types */ 86 | #define RAW 0 87 | #define ADIF 1 88 | #define ADTS 2 89 | #define LATM 3 90 | 91 | /* SBR signalling */ 92 | #define NO_SBR 0 93 | #define SBR_UPSAMPLED 1 94 | #define SBR_DOWNSAMPLED 2 95 | #define NO_SBR_UPSAMPLED 3 96 | 97 | /* library output formats */ 98 | #define FAAD_FMT_16BIT 1 99 | #define FAAD_FMT_24BIT 2 100 | #define FAAD_FMT_32BIT 3 101 | #define FAAD_FMT_FLOAT 4 102 | #define FAAD_FMT_FIXED FAAD_FMT_FLOAT 103 | #define FAAD_FMT_DOUBLE 5 104 | 105 | /* Capabilities */ 106 | #define LC_DEC_CAP (1<<0) /* Can decode LC */ 107 | #define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */ 108 | #define LTP_DEC_CAP (1<<2) /* Can decode LTP */ 109 | #define LD_DEC_CAP (1<<3) /* Can decode LD */ 110 | #define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */ 111 | #define FIXED_POINT_CAP (1<<5) /* Fixed point */ 112 | 113 | /* Channel definitions */ 114 | #define FRONT_CHANNEL_CENTER (1) 115 | #define FRONT_CHANNEL_LEFT (2) 116 | #define FRONT_CHANNEL_RIGHT (3) 117 | #define SIDE_CHANNEL_LEFT (4) 118 | #define SIDE_CHANNEL_RIGHT (5) 119 | #define BACK_CHANNEL_LEFT (6) 120 | #define BACK_CHANNEL_RIGHT (7) 121 | #define BACK_CHANNEL_CENTER (8) 122 | #define LFE_CHANNEL (9) 123 | #define UNKNOWN_CHANNEL (0) 124 | 125 | /* DRM channel definitions */ 126 | #define DRMCH_MONO 1 127 | #define DRMCH_STEREO 2 128 | #define DRMCH_SBR_MONO 3 129 | #define DRMCH_SBR_STEREO 4 130 | #define DRMCH_SBR_PS_STEREO 5 131 | 132 | 133 | /* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel, 134 | so at least so much bytes per channel should be available in this stream */ 135 | #define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */ 136 | 137 | 138 | typedef void *NeAACDecHandle; 139 | 140 | typedef struct mp4AudioSpecificConfig 141 | { 142 | /* Audio Specific Info */ 143 | unsigned char objectTypeIndex; 144 | unsigned char samplingFrequencyIndex; 145 | unsigned long samplingFrequency; 146 | unsigned char channelsConfiguration; 147 | 148 | /* GA Specific Info */ 149 | unsigned char frameLengthFlag; 150 | unsigned char dependsOnCoreCoder; 151 | unsigned short coreCoderDelay; 152 | unsigned char extensionFlag; 153 | unsigned char aacSectionDataResilienceFlag; 154 | unsigned char aacScalefactorDataResilienceFlag; 155 | unsigned char aacSpectralDataResilienceFlag; 156 | unsigned char epConfig; 157 | 158 | char sbr_present_flag; 159 | char forceUpSampling; 160 | char downSampledSBR; 161 | } mp4AudioSpecificConfig; 162 | 163 | typedef struct NeAACDecConfiguration 164 | { 165 | unsigned char defObjectType; 166 | unsigned long defSampleRate; 167 | unsigned char outputFormat; 168 | unsigned char downMatrix; 169 | unsigned char useOldADTSFormat; 170 | unsigned char dontUpSampleImplicitSBR; 171 | } NeAACDecConfiguration, *NeAACDecConfigurationPtr; 172 | 173 | typedef struct NeAACDecFrameInfo 174 | { 175 | unsigned long bytesconsumed; 176 | unsigned long samples; 177 | unsigned char channels; 178 | unsigned char error; 179 | unsigned long samplerate; 180 | 181 | /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */ 182 | unsigned char sbr; 183 | 184 | /* MPEG-4 ObjectType */ 185 | unsigned char object_type; 186 | 187 | /* AAC header type; MP4 will be signalled as RAW also */ 188 | unsigned char header_type; 189 | 190 | /* multichannel configuration */ 191 | unsigned char num_front_channels; 192 | unsigned char num_side_channels; 193 | unsigned char num_back_channels; 194 | unsigned char num_lfe_channels; 195 | unsigned char channel_position[64]; 196 | 197 | /* PS: 0: off, 1: on */ 198 | unsigned char ps; 199 | } NeAACDecFrameInfo; 200 | 201 | char* NEAACDECAPI NeAACDecGetErrorMessage(unsigned char errcode); 202 | 203 | unsigned long NEAACDECAPI NeAACDecGetCapabilities(void); 204 | 205 | NeAACDecHandle NEAACDECAPI NeAACDecOpen(void); 206 | 207 | NeAACDecConfigurationPtr NEAACDECAPI NeAACDecGetCurrentConfiguration(NeAACDecHandle hDecoder); 208 | 209 | unsigned char NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder, 210 | NeAACDecConfigurationPtr config); 211 | 212 | /* Init the library based on info from the AAC file (ADTS/ADIF) */ 213 | long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, 214 | unsigned char *buffer, 215 | unsigned long buffer_size, 216 | unsigned long *samplerate, 217 | unsigned char *channels); 218 | 219 | /* Init the library using a DecoderSpecificInfo */ 220 | char NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, 221 | unsigned char *pBuffer, 222 | unsigned long SizeOfDecoderSpecificInfo, 223 | unsigned long *samplerate, 224 | unsigned char *channels); 225 | 226 | /* Init the library for DRM */ 227 | char NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, unsigned long samplerate, 228 | unsigned char channels); 229 | 230 | void NEAACDECAPI NeAACDecPostSeekReset(NeAACDecHandle hDecoder, long frame); 231 | 232 | void NEAACDECAPI NeAACDecClose(NeAACDecHandle hDecoder); 233 | 234 | void* NEAACDECAPI NeAACDecDecode(NeAACDecHandle hDecoder, 235 | NeAACDecFrameInfo *hInfo, 236 | unsigned char *buffer, 237 | unsigned long buffer_size); 238 | 239 | void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder, 240 | NeAACDecFrameInfo *hInfo, 241 | unsigned char *buffer, 242 | unsigned long buffer_size, 243 | void **sample_buffer, 244 | unsigned long sample_buffer_size); 245 | 246 | char NEAACDECAPI NeAACDecAudioSpecificConfig(unsigned char *pBuffer, 247 | unsigned long buffer_size, 248 | mp4AudioSpecificConfig *mp4ASC); 249 | 250 | #ifdef _WIN32 251 | #pragma pack(pop) 252 | #endif 253 | 254 | #ifdef __cplusplus 255 | } 256 | #endif /* __cplusplus */ 257 | 258 | #endif 259 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faad/lib/libfaad.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo/faad/lib/libfaad.a -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/faad/lib/libmp4ff.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo/faad/lib/libmp4ff.a -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ESCAACCoderDemo 4 | // 5 | // Created by xiang on 2018/10/9. 6 | // Copyright © 2018年 xiang. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/vocal.aac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo/vocal.aac -------------------------------------------------------------------------------- /ESCAACCoderDemo/ESCAACCoderDemo/vocal.pcm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XMSECODE/ESCAACCoderDemo/f0c9471efa050fda56296a79ba6691eaf1c21379/ESCAACCoderDemo/ESCAACCoderDemo/vocal.pcm -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESCAACCoderDemo 2 | AAC to PCM and PCM to AAC. 3 | --------------------------------------------------------------------------------