5031 changed files with 90 additions and 64436 deletions
@ -0,0 +1,90 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# 清理Xcode DerivedData |
||||
|
echo "清理Xcode DerivedData..." |
||||
|
rm -rf ~/Library/Developer/Xcode/DerivedData/* |
||||
|
|
||||
|
# 清理SPM缓存 |
||||
|
echo "清理SPM缓存..." |
||||
|
rm -rf ~/Library/Caches/org.swift.swiftpm/ |
||||
|
|
||||
|
# 进入项目根目录 |
||||
|
cd /Users/wolfplus/Developer/deep_voice |
||||
|
|
||||
|
# 清理各个插件的SPM生成目录 |
||||
|
echo "开始清理各插件的SPM生成目录..." |
||||
|
|
||||
|
# 1. agent_service |
||||
|
echo "清理 agent_service..." |
||||
|
cd local_plugins/agent_service/ios/agent_service |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 2. azure_speech |
||||
|
echo "清理 azure_speech..." |
||||
|
cd local_plugins/azure_speech/ios/azure_speech |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 3. ble_service |
||||
|
echo "清理 ble_service..." |
||||
|
cd local_plugins/ble_service/ios/ble_service |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 4. chat_api |
||||
|
echo "清理 chat_api..." |
||||
|
cd local_plugins/chat_api/ios/chat_api |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 5. chat_storage |
||||
|
echo "清理 chat_storage..." |
||||
|
cd local_plugins/chat_storage/ios/chat_storage |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 6. open_ai_service |
||||
|
echo "清理 open_ai_service..." |
||||
|
cd local_plugins/open_ai_service/ios/open_ai_service |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 7. speech |
||||
|
echo "清理 speech..." |
||||
|
cd local_plugins/speech/ios/speech |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
# 8. test |
||||
|
echo "清理 test..." |
||||
|
cd local_plugins/test/ios/test |
||||
|
rm -rf .build |
||||
|
rm -f Package.resolved |
||||
|
rm -f workspace-state.json |
||||
|
cd ../../../../ |
||||
|
|
||||
|
echo "所有插件清理完成!" |
||||
|
|
||||
|
# 额外清理项目级别的SPM文件 |
||||
|
echo "清理项目级别的SPM文件..." |
||||
|
rm -rf ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/ |
||||
|
rm -rf ios/Runner.xcworkspace/xcshareddata/swiftpm/ |
||||
|
rm -rf macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/ |
||||
|
rm -rf macos/Runner.xcworkspace/xcshareddata/swiftpm/ |
||||
|
|
||||
|
echo "全部清理完成!" |
||||
@ -1,285 +0,0 @@ |
|||||
{ |
|
||||
"originHash" : "fb7ecff82f4ff109531189491cc6cc2299a7357c61874f58bae1e0f7b7d9e8d0", |
|
||||
"pins" : [ |
|
||||
{ |
|
||||
"identity" : "abseil-cpp-binary", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/abseil-cpp-binary.git", |
|
||||
"state" : { |
|
||||
"revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5", |
|
||||
"version" : "1.2024072200.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "app-check", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/app-check.git", |
|
||||
"state" : { |
|
||||
"revision" : "61b85103a1aeed8218f17c794687781505fbbef5", |
|
||||
"version" : "11.2.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "appauth-ios", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/openid/AppAuth-iOS.git", |
|
||||
"state" : { |
|
||||
"revision" : "2781038865a80e2c425a1da12cc1327bcd56501f", |
|
||||
"version" : "1.7.6" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkcamera", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKCamera", |
|
||||
"state" : { |
|
||||
"branch" : "master", |
|
||||
"revision" : "5c691d11014b910aff69f960475d70e65d9dcc96" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkimagepickercontroller", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKImagePickerController", |
|
||||
"state" : { |
|
||||
"branch" : "4.3.9", |
|
||||
"revision" : "0bdfeacefa308545adde07bef86e349186335915" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkphotogallery", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKPhotoGallery", |
|
||||
"state" : { |
|
||||
"branch" : "master", |
|
||||
"revision" : "311c1bc7a94f1538f82773a79c84374b12a2ef3d" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "eventsource", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/loopwork-ai/eventsource.git", |
|
||||
"state" : { |
|
||||
"revision" : "07957602bb99a5355c810187e66e6ce378a1057d", |
|
||||
"version" : "1.1.1" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "firebase-ios-sdk", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/firebase-ios-sdk", |
|
||||
"state" : { |
|
||||
"revision" : "3663b1aa6c7a1bed67ee80fd09dc6d0f9c3bb660", |
|
||||
"version" : "11.13.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "flutterfire", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/flutterfire", |
|
||||
"state" : { |
|
||||
"revision" : "7bd63691ffa7405d24ea4545bd1ac7f8971175b3", |
|
||||
"version" : "3.13.1-firebase-core-swift" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googleappmeasurement", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleAppMeasurement.git", |
|
||||
"state" : { |
|
||||
"revision" : "543071966b3fb6613a2fc5c6e7112d1e998184a7", |
|
||||
"version" : "11.13.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googledatatransport", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleDataTransport.git", |
|
||||
"state" : { |
|
||||
"revision" : "617af071af9aa1d6a091d59a202910ac482128f9", |
|
||||
"version" : "10.1.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googlesignin-ios", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleSignIn-iOS.git", |
|
||||
"state" : { |
|
||||
"revision" : "65fb3f1aa6ffbfdc79c4e22178a55cd91561f5e9", |
|
||||
"version" : "8.0.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googleutilities", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleUtilities.git", |
|
||||
"state" : { |
|
||||
"revision" : "60da361632d0de02786f709bdc0c4df340f7613e", |
|
||||
"version" : "8.1.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "grpc-binary", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/grpc-binary.git", |
|
||||
"state" : { |
|
||||
"revision" : "cc0001a0cf963aa40501d9c2b181e7fc9fd8ec71", |
|
||||
"version" : "1.69.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "gtm-session-fetcher", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/gtm-session-fetcher.git", |
|
||||
"state" : { |
|
||||
"revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b", |
|
||||
"version" : "3.5.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "gtmappauth", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GTMAppAuth.git", |
|
||||
"state" : { |
|
||||
"revision" : "5d7d66f647400952b1758b230e019b07c0b4b22a", |
|
||||
"version" : "4.1.1" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "interop-ios-for-google-sdks", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/interop-ios-for-google-sdks.git", |
|
||||
"state" : { |
|
||||
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe", |
|
||||
"version" : "101.0.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "leveldb", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/leveldb.git", |
|
||||
"state" : { |
|
||||
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1", |
|
||||
"version" : "1.22.5" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "nanopb", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/nanopb.git", |
|
||||
"state" : { |
|
||||
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1", |
|
||||
"version" : "2.30910.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "openai", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/MacPaw/OpenAI.git", |
|
||||
"state" : { |
|
||||
"revision" : "9261cd39d55a718bcc360fbc29515a331cad5dbb", |
|
||||
"version" : "0.4.3" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "opus-swift", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/ybrid/opus-swift.git", |
|
||||
"state" : { |
|
||||
"revision" : "92e76803ce7efc8e8903433cfd5f7f68938534ba", |
|
||||
"version" : "0.8.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "promises", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/promises.git", |
|
||||
"state" : { |
|
||||
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac", |
|
||||
"version" : "2.4.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "sdwebimage", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/SDWebImage/SDWebImage", |
|
||||
"state" : { |
|
||||
"revision" : "cac9a55a3ae92478a2c95042dcc8d9695d2129ca", |
|
||||
"version" : "5.21.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-http-types", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-http-types", |
|
||||
"state" : { |
|
||||
"revision" : "a0a57e949a8903563aba4615869310c0ebf14c03", |
|
||||
"version" : "1.4.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-log", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-log.git", |
|
||||
"state" : { |
|
||||
"revision" : "3d8596ed08bd13520157f0355e35caed215ffbfa", |
|
||||
"version" : "1.6.3" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-openapi-runtime", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-openapi-runtime", |
|
||||
"state" : { |
|
||||
"revision" : "8f33cc5dfe81169fb167da73584b9c72c3e8bc23", |
|
||||
"version" : "1.8.2" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-protobuf", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-protobuf.git", |
|
||||
"state" : { |
|
||||
"revision" : "d72aed98f8253ec1aa9ea1141e28150f408cf17f", |
|
||||
"version" : "1.29.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-sdk", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/modelcontextprotocol/swift-sdk.git", |
|
||||
"state" : { |
|
||||
"revision" : "9742933d2ff250212a04aed39b123bcc63a21e9c", |
|
||||
"version" : "0.9.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-system", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-system.git", |
|
||||
"state" : { |
|
||||
"revision" : "61e4ca4b81b9e09e2ec863b00c340eb13497dac6", |
|
||||
"version" : "1.5.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swiftygif", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/kirualex/SwiftyGif.git", |
|
||||
"state" : { |
|
||||
"revision" : "4430cbc148baa3907651d40562d96325426f409a", |
|
||||
"version" : "5.4.5" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "tocropviewcontroller", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/TimOliver/TOCropViewController", |
|
||||
"state" : { |
|
||||
"revision" : "a634cb7cdfd580006e79a6e74e64417fe9e9783b", |
|
||||
"version" : "2.7.4" |
|
||||
} |
|
||||
} |
|
||||
], |
|
||||
"version" : 3 |
|
||||
} |
|
||||
@ -1,285 +0,0 @@ |
|||||
{ |
|
||||
"originHash" : "fb7ecff82f4ff109531189491cc6cc2299a7357c61874f58bae1e0f7b7d9e8d0", |
|
||||
"pins" : [ |
|
||||
{ |
|
||||
"identity" : "abseil-cpp-binary", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/abseil-cpp-binary.git", |
|
||||
"state" : { |
|
||||
"revision" : "bbe8b69694d7873315fd3a4ad41efe043e1c07c5", |
|
||||
"version" : "1.2024072200.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "app-check", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/app-check.git", |
|
||||
"state" : { |
|
||||
"revision" : "61b85103a1aeed8218f17c794687781505fbbef5", |
|
||||
"version" : "11.2.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "appauth-ios", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/openid/AppAuth-iOS.git", |
|
||||
"state" : { |
|
||||
"revision" : "2781038865a80e2c425a1da12cc1327bcd56501f", |
|
||||
"version" : "1.7.6" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkcamera", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKCamera", |
|
||||
"state" : { |
|
||||
"branch" : "master", |
|
||||
"revision" : "5c691d11014b910aff69f960475d70e65d9dcc96" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkimagepickercontroller", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKImagePickerController", |
|
||||
"state" : { |
|
||||
"branch" : "4.3.9", |
|
||||
"revision" : "0bdfeacefa308545adde07bef86e349186335915" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "dkphotogallery", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/zhangao0086/DKPhotoGallery", |
|
||||
"state" : { |
|
||||
"branch" : "master", |
|
||||
"revision" : "311c1bc7a94f1538f82773a79c84374b12a2ef3d" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "eventsource", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/loopwork-ai/eventsource.git", |
|
||||
"state" : { |
|
||||
"revision" : "07957602bb99a5355c810187e66e6ce378a1057d", |
|
||||
"version" : "1.1.1" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "firebase-ios-sdk", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/firebase-ios-sdk", |
|
||||
"state" : { |
|
||||
"revision" : "3663b1aa6c7a1bed67ee80fd09dc6d0f9c3bb660", |
|
||||
"version" : "11.13.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "flutterfire", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/flutterfire", |
|
||||
"state" : { |
|
||||
"revision" : "7bd63691ffa7405d24ea4545bd1ac7f8971175b3", |
|
||||
"version" : "3.13.1-firebase-core-swift" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googleappmeasurement", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleAppMeasurement.git", |
|
||||
"state" : { |
|
||||
"revision" : "543071966b3fb6613a2fc5c6e7112d1e998184a7", |
|
||||
"version" : "11.13.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googledatatransport", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleDataTransport.git", |
|
||||
"state" : { |
|
||||
"revision" : "617af071af9aa1d6a091d59a202910ac482128f9", |
|
||||
"version" : "10.1.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googlesignin-ios", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleSignIn-iOS.git", |
|
||||
"state" : { |
|
||||
"revision" : "65fb3f1aa6ffbfdc79c4e22178a55cd91561f5e9", |
|
||||
"version" : "8.0.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "googleutilities", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GoogleUtilities.git", |
|
||||
"state" : { |
|
||||
"revision" : "60da361632d0de02786f709bdc0c4df340f7613e", |
|
||||
"version" : "8.1.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "grpc-binary", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/grpc-binary.git", |
|
||||
"state" : { |
|
||||
"revision" : "cc0001a0cf963aa40501d9c2b181e7fc9fd8ec71", |
|
||||
"version" : "1.69.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "gtm-session-fetcher", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/gtm-session-fetcher.git", |
|
||||
"state" : { |
|
||||
"revision" : "a2ab612cb980066ee56d90d60d8462992c07f24b", |
|
||||
"version" : "3.5.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "gtmappauth", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/GTMAppAuth.git", |
|
||||
"state" : { |
|
||||
"revision" : "5d7d66f647400952b1758b230e019b07c0b4b22a", |
|
||||
"version" : "4.1.1" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "interop-ios-for-google-sdks", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/interop-ios-for-google-sdks.git", |
|
||||
"state" : { |
|
||||
"revision" : "040d087ac2267d2ddd4cca36c757d1c6a05fdbfe", |
|
||||
"version" : "101.0.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "leveldb", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/leveldb.git", |
|
||||
"state" : { |
|
||||
"revision" : "a0bc79961d7be727d258d33d5a6b2f1023270ba1", |
|
||||
"version" : "1.22.5" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "nanopb", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/firebase/nanopb.git", |
|
||||
"state" : { |
|
||||
"revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1", |
|
||||
"version" : "2.30910.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "openai", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/MacPaw/OpenAI.git", |
|
||||
"state" : { |
|
||||
"revision" : "9261cd39d55a718bcc360fbc29515a331cad5dbb", |
|
||||
"version" : "0.4.3" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "opus-swift", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/ybrid/opus-swift.git", |
|
||||
"state" : { |
|
||||
"revision" : "92e76803ce7efc8e8903433cfd5f7f68938534ba", |
|
||||
"version" : "0.8.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "promises", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/google/promises.git", |
|
||||
"state" : { |
|
||||
"revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac", |
|
||||
"version" : "2.4.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "sdwebimage", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/SDWebImage/SDWebImage", |
|
||||
"state" : { |
|
||||
"revision" : "cac9a55a3ae92478a2c95042dcc8d9695d2129ca", |
|
||||
"version" : "5.21.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-http-types", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-http-types", |
|
||||
"state" : { |
|
||||
"revision" : "a0a57e949a8903563aba4615869310c0ebf14c03", |
|
||||
"version" : "1.4.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-log", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-log.git", |
|
||||
"state" : { |
|
||||
"revision" : "3d8596ed08bd13520157f0355e35caed215ffbfa", |
|
||||
"version" : "1.6.3" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-openapi-runtime", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-openapi-runtime", |
|
||||
"state" : { |
|
||||
"revision" : "8f33cc5dfe81169fb167da73584b9c72c3e8bc23", |
|
||||
"version" : "1.8.2" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-protobuf", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-protobuf.git", |
|
||||
"state" : { |
|
||||
"revision" : "102a647b573f60f73afdce5613a51d71349fe507", |
|
||||
"version" : "1.30.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-sdk", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/modelcontextprotocol/swift-sdk.git", |
|
||||
"state" : { |
|
||||
"revision" : "9742933d2ff250212a04aed39b123bcc63a21e9c", |
|
||||
"version" : "0.9.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swift-system", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/apple/swift-system.git", |
|
||||
"state" : { |
|
||||
"revision" : "61e4ca4b81b9e09e2ec863b00c340eb13497dac6", |
|
||||
"version" : "1.5.0" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "swiftygif", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/kirualex/SwiftyGif.git", |
|
||||
"state" : { |
|
||||
"revision" : "4430cbc148baa3907651d40562d96325426f409a", |
|
||||
"version" : "5.4.5" |
|
||||
} |
|
||||
}, |
|
||||
{ |
|
||||
"identity" : "tocropviewcontroller", |
|
||||
"kind" : "remoteSourceControl", |
|
||||
"location" : "https://github.com/TimOliver/TOCropViewController", |
|
||||
"state" : { |
|
||||
"revision" : "a634cb7cdfd580006e79a6e74e64417fe9e9783b", |
|
||||
"version" : "2.7.4" |
|
||||
} |
|
||||
} |
|
||||
], |
|
||||
"version" : 3 |
|
||||
} |
|
||||
@ -1,69 +0,0 @@ |
|||||
<?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>AvailableLibraries</key> |
|
||||
<array> |
|
||||
<dict> |
|
||||
<key>LibraryIdentifier</key> |
|
||||
<string>ios-arm64_armv7</string> |
|
||||
<key>LibraryPath</key> |
|
||||
<string>YbridOpus.framework</string> |
|
||||
<key>SupportedArchitectures</key> |
|
||||
<array> |
|
||||
<string>arm64</string> |
|
||||
<string>armv7</string> |
|
||||
</array> |
|
||||
<key>SupportedPlatform</key> |
|
||||
<string>ios</string> |
|
||||
</dict> |
|
||||
<dict> |
|
||||
<key>LibraryIdentifier</key> |
|
||||
<string>ios-arm64_x86_64-maccatalyst</string> |
|
||||
<key>LibraryPath</key> |
|
||||
<string>YbridOpus.framework</string> |
|
||||
<key>SupportedArchitectures</key> |
|
||||
<array> |
|
||||
<string>arm64</string> |
|
||||
<string>x86_64</string> |
|
||||
</array> |
|
||||
<key>SupportedPlatform</key> |
|
||||
<string>ios</string> |
|
||||
<key>SupportedPlatformVariant</key> |
|
||||
<string>maccatalyst</string> |
|
||||
</dict> |
|
||||
<dict> |
|
||||
<key>LibraryIdentifier</key> |
|
||||
<string>ios-i386_x86_64-simulator</string> |
|
||||
<key>LibraryPath</key> |
|
||||
<string>YbridOpus.framework</string> |
|
||||
<key>SupportedArchitectures</key> |
|
||||
<array> |
|
||||
<string>i386</string> |
|
||||
<string>x86_64</string> |
|
||||
</array> |
|
||||
<key>SupportedPlatform</key> |
|
||||
<string>ios</string> |
|
||||
<key>SupportedPlatformVariant</key> |
|
||||
<string>simulator</string> |
|
||||
</dict> |
|
||||
<dict> |
|
||||
<key>LibraryIdentifier</key> |
|
||||
<string>macos-arm64_x86_64</string> |
|
||||
<key>LibraryPath</key> |
|
||||
<string>YbridOpus.framework</string> |
|
||||
<key>SupportedArchitectures</key> |
|
||||
<array> |
|
||||
<string>arm64</string> |
|
||||
<string>x86_64</string> |
|
||||
</array> |
|
||||
<key>SupportedPlatform</key> |
|
||||
<string>macos</string> |
|
||||
</dict> |
|
||||
</array> |
|
||||
<key>CFBundlePackageType</key> |
|
||||
<string>XFWK</string> |
|
||||
<key>XCFrameworkFormatVersion</key> |
|
||||
<string>1.0</string> |
|
||||
</dict> |
|
||||
</plist> |
|
||||
@ -1,34 +0,0 @@ |
|||||
MIT License |
|
||||
|
|
||||
Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
|
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
|
||||
|
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||
|
|
||||
|
|
||||
3rd party licenses |
|
||||
opus |
|
||||
Project opus-swift creates binaries from opus sources available on [opus-codec.org/downloads](https://opus-codec.org/downloads/). |
|
||||
Both the reference implementation and the revised implementations on opus-codec.org are available under the three-clause BSD license. This BSD license is compatible with all common open source and commercial software licenses, see [details](https://opus-codec.org/license). |
|
||||
|
|
||||
Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic, Jean-Marc Valin, Timothy B. Terriberry, |
|
||||
CSIRO, Gregory Maxwell, Mark Borgerding, Erik de Castro Lopo |
|
||||
|
|
||||
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. |
|
||||
Neither the name of Internet Society, IETF or IETF Trust, nor the names of specific contributors, may be used to endorse or promote products derived from this software without specific prior written permission. |
|
||||
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. |
|
||||
|
|
||||
Opus is subject to the royalty-free patent licenses which are specified at: |
|
||||
|
|
||||
Xiph.Org Foundation: |
|
||||
https://datatracker.ietf.org/ipr/1524/ |
|
||||
|
|
||||
Microsoft Corporation: |
|
||||
https://datatracker.ietf.org/ipr/1914/ |
|
||||
|
|
||||
Broadcom Corporation: |
|
||||
https://datatracker.ietf.org/ipr/1526/ |
|
||||
@ -1,43 +0,0 @@ |
|||||
// |
|
||||
// Config.xcconfig |
|
||||
// opus-swift |
|
||||
// |
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
// |
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
// of this software and associated documentation files (the "Software"), to deal |
|
||||
// in the Software without restriction, including without limitation the rights |
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
// copies of the Software, and to permit persons to whom the Software is |
|
||||
// furnished to do so, subject to the following conditions: |
|
||||
// |
|
||||
// The above copyright notice and this permission notice shall be included in all |
|
||||
// copies or substantial portions of the Software. |
|
||||
// |
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||
// SOFTWARE. |
|
||||
// |
|
||||
|
|
||||
// Configuration settings file format documentation can be found at: |
|
||||
// https://help.apple.com/xcode/#/dev745c5c974 |
|
||||
|
|
||||
// Product Version, PLEASE CHANGE HERE to affect all targets |
|
||||
MARKETING_VERSION = 0.8.0 |
|
||||
// Build number, PLEASE CHANGE HERE to affect all targets |
|
||||
CURRENT_PROJECT_VERSION = 3 |
|
||||
|
|
||||
|
|
||||
ARCHS = arm64 armv7 x86_64 x86_64h i386 |
|
||||
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 |
|
||||
EXCLUDED_ARCHS[sdk=macosx*] = i386 |
|
||||
SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx |
|
||||
|
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0 |
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10 |
|
||||
|
|
||||
SWIFT_VERSION = 4.0 |
|
||||
@ -1,981 +0,0 @@ |
|||||
/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
|
|
||||
Written by Jean-Marc Valin and Koen Vos */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus.h |
|
||||
* @brief Opus reference implementation API |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_H |
|
||||
#define OPUS_H |
|
||||
|
|
||||
#include "opus_types.h" |
|
||||
#include "opus_defines.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/**
|
|
||||
* @mainpage Opus |
|
||||
* |
|
||||
* The Opus codec is designed for interactive speech and audio transmission over the Internet. |
|
||||
* It is designed by the IETF Codec Working Group and incorporates technology from |
|
||||
* Skype's SILK codec and Xiph.Org's CELT codec. |
|
||||
* |
|
||||
* The Opus codec is designed to handle a wide range of interactive audio applications, |
|
||||
* including Voice over IP, videoconferencing, in-game chat, and even remote live music |
|
||||
* performances. It can scale from low bit-rate narrowband speech to very high quality |
|
||||
* stereo music. Its main features are: |
|
||||
|
|
||||
* @li Sampling rates from 8 to 48 kHz |
|
||||
* @li Bit-rates from 6 kb/s to 510 kb/s |
|
||||
* @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR) |
|
||||
* @li Audio bandwidth from narrowband to full-band |
|
||||
* @li Support for speech and music |
|
||||
* @li Support for mono and stereo |
|
||||
* @li Support for multichannel (up to 255 channels) |
|
||||
* @li Frame sizes from 2.5 ms to 60 ms |
|
||||
* @li Good loss robustness and packet loss concealment (PLC) |
|
||||
* @li Floating point and fixed-point implementation |
|
||||
* |
|
||||
* Documentation sections: |
|
||||
* @li @ref opus_encoder |
|
||||
* @li @ref opus_decoder |
|
||||
* @li @ref opus_repacketizer |
|
||||
* @li @ref opus_multistream |
|
||||
* @li @ref opus_libinfo |
|
||||
* @li @ref opus_custom |
|
||||
*/ |
|
||||
|
|
||||
/** @defgroup opus_encoder Opus Encoder
|
|
||||
* @{ |
|
||||
* |
|
||||
* @brief This page describes the process and functions used to encode Opus. |
|
||||
* |
|
||||
* Since Opus is a stateful codec, the encoding process starts with creating an encoder |
|
||||
* state. This can be done with: |
|
||||
* |
|
||||
* @code |
|
||||
* int error; |
|
||||
* OpusEncoder *enc; |
|
||||
* enc = opus_encoder_create(Fs, channels, application, &error); |
|
||||
* @endcode |
|
||||
* |
|
||||
* From this point, @c enc can be used for encoding an audio stream. An encoder state |
|
||||
* @b must @b not be used for more than one stream at the same time. Similarly, the encoder |
|
||||
* state @b must @b not be re-initialized for each frame. |
|
||||
* |
|
||||
* While opus_encoder_create() allocates memory for the state, it's also possible |
|
||||
* to initialize pre-allocated memory: |
|
||||
* |
|
||||
* @code |
|
||||
* int size; |
|
||||
* int error; |
|
||||
* OpusEncoder *enc; |
|
||||
* size = opus_encoder_get_size(channels); |
|
||||
* enc = malloc(size); |
|
||||
* error = opus_encoder_init(enc, Fs, channels, application); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where opus_encoder_get_size() returns the required size for the encoder state. Note that |
|
||||
* future versions of this code may change the size, so no assuptions should be made about it. |
|
||||
* |
|
||||
* The encoder state is always continuous in memory and only a shallow copy is sufficient |
|
||||
* to copy it (e.g. memcpy()) |
|
||||
* |
|
||||
* It is possible to change some of the encoder's settings using the opus_encoder_ctl() |
|
||||
* interface. All these settings already default to the recommended value, so they should |
|
||||
* only be changed when necessary. The most common settings one may want to change are: |
|
||||
* |
|
||||
* @code |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate)); |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type)); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where |
|
||||
* |
|
||||
* @arg bitrate is in bits per second (b/s) |
|
||||
* @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest |
|
||||
* @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC |
|
||||
* |
|
||||
* See @ref opus_encoderctls and @ref opus_genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream. |
|
||||
* |
|
||||
* To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data: |
|
||||
* @code |
|
||||
* len = opus_encode(enc, audio_frame, frame_size, packet, max_packet); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where |
|
||||
* <ul> |
|
||||
* <li>audio_frame is the audio data in opus_int16 (or float for opus_encode_float())</li> |
|
||||
* <li>frame_size is the duration of the frame in samples (per channel)</li> |
|
||||
* <li>packet is the byte array to which the compressed data is written</li> |
|
||||
* <li>max_packet is the maximum number of bytes that can be written in the packet (4000 bytes is recommended). |
|
||||
* Do not use max_packet to control VBR target bitrate, instead use the #OPUS_SET_BITRATE CTL.</li> |
|
||||
* </ul> |
|
||||
* |
|
||||
* opus_encode() and opus_encode_float() return the number of bytes actually written to the packet. |
|
||||
* The return value <b>can be negative</b>, which indicates that an error has occurred. If the return value |
|
||||
* is 2 bytes or less, then the packet does not need to be transmitted (DTX). |
|
||||
* |
|
||||
* Once the encoder state if no longer needed, it can be destroyed with |
|
||||
* |
|
||||
* @code |
|
||||
* opus_encoder_destroy(enc); |
|
||||
* @endcode |
|
||||
* |
|
||||
* If the encoder was created with opus_encoder_init() rather than opus_encoder_create(), |
|
||||
* then no action is required aside from potentially freeing the memory that was manually |
|
||||
* allocated for it (calling free(enc) for the example above) |
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
/** Opus encoder state.
|
|
||||
* This contains the complete state of an Opus encoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_encoder_create,opus_encoder_init |
|
||||
*/ |
|
||||
typedef struct OpusEncoder OpusEncoder; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusEncoder</code> structure.
|
|
||||
* @param[in] channels <tt>int</tt>: Number of channels. |
|
||||
* This must be 1 or 2. |
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels); |
|
||||
|
|
||||
/**
|
|
||||
*/ |
|
||||
|
|
||||
/** Allocates and initializes an encoder state.
|
|
||||
* There are three coding modes: |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice |
|
||||
* signals. It enhances the input signal by high-pass filtering and |
|
||||
* emphasizing formants and harmonics. Optionally it includes in-band |
|
||||
* forward error correction to protect against packet loss. Use this |
|
||||
* mode for typical VoIP applications. Because of the enhancement, |
|
||||
* even at high bitrates the output may sound different from the input. |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for most |
|
||||
* non-voice signals like music. Use this mode for music and mixed |
|
||||
* (music/voice) content, broadcast, and applications requiring less |
|
||||
* than 15 ms of coding delay. |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that |
|
||||
* disables the speech-optimized mode in exchange for slightly reduced delay. |
|
||||
* This mode can only be set on an newly initialized or freshly reset encoder |
|
||||
* because it changes the codec delay. |
|
||||
* |
|
||||
* This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution). |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
|
||||
* @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
|
||||
* @param [out] error <tt>int*</tt>: @ref opus_errorcodes |
|
||||
* @note Regardless of the sampling rate and number channels selected, the Opus encoder |
|
||||
* can switch to a lower audio bandwidth or number of channels if the bitrate |
|
||||
* selected is too low. This also means that it is safe to always use 48 kHz stereo input |
|
||||
* and let the encoder optimize the encoding. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int application, |
|
||||
int *error |
|
||||
); |
|
||||
|
|
||||
/** Initializes a previously allocated encoder state
|
|
||||
* The memory pointed to by st must be at least the size returned by opus_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of malloc. |
|
||||
* @see opus_encoder_create(),opus_encoder_get_size() |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
|
||||
* @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
|
||||
* @retval #OPUS_OK Success or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_encoder_init( |
|
||||
OpusEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Encodes an Opus frame.
|
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16) |
|
||||
* @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
|
||||
* input signal. |
|
||||
* This must be an Opus frame size for |
|
||||
* the encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted |
|
||||
* values are 120, 240, 480, 960, 1920, |
|
||||
* and 2880. |
|
||||
* Passing in a duration of less than |
|
||||
* 10 ms (480 samples at 48 kHz) will |
|
||||
* prevent the encoder from using the LPC |
|
||||
* or hybrid modes. |
|
||||
* @param [out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode( |
|
||||
OpusEncoder *st, |
|
||||
const opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Encodes an Opus frame from floating point input.
|
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] pcm <tt>float*</tt>: Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. |
|
||||
* Samples with a range beyond +/-1.0 are supported but will |
|
||||
* be clipped by decoders using the integer API and should |
|
||||
* only be used if it is known that the far end supports |
|
||||
* extended dynamic range. |
|
||||
* length is frame_size*channels*sizeof(float) |
|
||||
* @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
|
||||
* input signal. |
|
||||
* This must be an Opus frame size for |
|
||||
* the encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted |
|
||||
* values are 120, 240, 480, 960, 1920, |
|
||||
* and 2880. |
|
||||
* Passing in a duration of less than |
|
||||
* 10 ms (480 samples at 48 kHz) will |
|
||||
* prevent the encoder from using the LPC |
|
||||
* or hybrid modes. |
|
||||
* @param [out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float( |
|
||||
OpusEncoder *st, |
|
||||
const float *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Frees an <code>OpusEncoder</code> allocated by opus_encoder_create().
|
|
||||
* @param[in] st <tt>OpusEncoder*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st); |
|
||||
|
|
||||
/** Perform a CTL function on an Opus encoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated |
|
||||
* by a convenience macro. |
|
||||
* @param st <tt>OpusEncoder*</tt>: Encoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls or |
|
||||
* @ref opus_encoderctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_encoderctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_decoder Opus Decoder
|
|
||||
* @{ |
|
||||
* |
|
||||
* @brief This page describes the process and functions used to decode Opus. |
|
||||
* |
|
||||
* The decoding process also starts with creating a decoder |
|
||||
* state. This can be done with: |
|
||||
* @code |
|
||||
* int error; |
|
||||
* OpusDecoder *dec; |
|
||||
* dec = opus_decoder_create(Fs, channels, &error); |
|
||||
* @endcode |
|
||||
* where |
|
||||
* @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000 |
|
||||
* @li channels is the number of channels (1 or 2) |
|
||||
* @li error will hold the error code in case of failure (or #OPUS_OK on success) |
|
||||
* @li the return value is a newly created decoder state to be used for decoding |
|
||||
* |
|
||||
* While opus_decoder_create() allocates memory for the state, it's also possible |
|
||||
* to initialize pre-allocated memory: |
|
||||
* @code |
|
||||
* int size; |
|
||||
* int error; |
|
||||
* OpusDecoder *dec; |
|
||||
* size = opus_decoder_get_size(channels); |
|
||||
* dec = malloc(size); |
|
||||
* error = opus_decoder_init(dec, Fs, channels); |
|
||||
* @endcode |
|
||||
* where opus_decoder_get_size() returns the required size for the decoder state. Note that |
|
||||
* future versions of this code may change the size, so no assuptions should be made about it. |
|
||||
* |
|
||||
* The decoder state is always continuous in memory and only a shallow copy is sufficient |
|
||||
* to copy it (e.g. memcpy()) |
|
||||
* |
|
||||
* To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data: |
|
||||
* @code |
|
||||
* frame_size = opus_decode(dec, packet, len, decoded, max_size, 0); |
|
||||
* @endcode |
|
||||
* where |
|
||||
* |
|
||||
* @li packet is the byte array containing the compressed data |
|
||||
* @li len is the exact number of bytes contained in the packet |
|
||||
* @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float()) |
|
||||
* @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array |
|
||||
* |
|
||||
* opus_decode() and opus_decode_float() return the number of samples (per channel) decoded from the packet. |
|
||||
* If that value is negative, then an error has occurred. This can occur if the packet is corrupted or if the audio |
|
||||
* buffer is too small to hold the decoded audio. |
|
||||
* |
|
||||
* Opus is a stateful codec with overlapping blocks and as a result Opus |
|
||||
* packets are not coded independently of each other. Packets must be |
|
||||
* passed into the decoder serially and in the correct order for a correct |
|
||||
* decode. Lost packets can be replaced with loss concealment by calling |
|
||||
* the decoder with a null pointer and zero length for the missing packet. |
|
||||
* |
|
||||
* A single codec state may only be accessed from a single thread at |
|
||||
* a time and any required locking must be performed by the caller. Separate |
|
||||
* streams must be decoded with separate decoder states and can be decoded |
|
||||
* in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK |
|
||||
* defined. |
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
/** Opus decoder state.
|
|
||||
* This contains the complete state of an Opus decoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_decoder_create,opus_decoder_init |
|
||||
*/ |
|
||||
typedef struct OpusDecoder OpusDecoder; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusDecoder</code> structure.
|
|
||||
* @param [in] channels <tt>int</tt>: Number of channels. |
|
||||
* This must be 1 or 2. |
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels); |
|
||||
|
|
||||
/** Allocates and initializes a decoder state.
|
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sample rate to decode at (Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
|
||||
* @param [out] error <tt>int*</tt>: #OPUS_OK Success or @ref opus_errorcodes |
|
||||
* |
|
||||
* Internally Opus stores data at 48000 Hz, so that should be the default |
|
||||
* value for Fs. However, the decoder can efficiently decode to buffers |
|
||||
* at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use |
|
||||
* data at the full sample rate, or knows the compressed data doesn't |
|
||||
* use the full frequency range, it can request decoding at a reduced |
|
||||
* rate. Likewise, the decoder is capable of filling in either mono or |
|
||||
* interleaved stereo pcm buffers, at the caller's request. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int *error |
|
||||
); |
|
||||
|
|
||||
/** Initializes a previously allocated decoder state.
|
|
||||
* The state must be at least the size returned by opus_decoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state. |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate to decode to (Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
|
||||
* @retval #OPUS_OK Success or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_decoder_init( |
|
||||
OpusDecoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels |
|
||||
) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Decode an Opus packet.
|
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
|
||||
* @param [in] len <tt>opus_int32</tt>: Number of bytes in payload* |
|
||||
* @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length |
|
||||
* is frame_size*channels*sizeof(opus_int16) |
|
||||
* @param [in] frame_size Number of samples per channel of available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
|
||||
* not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
|
||||
* then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
|
||||
* FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
|
||||
* decoded. If no such data is available, the frame is decoded as if it were lost. |
|
||||
* @returns Number of decoded samples or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode( |
|
||||
OpusDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Decode an Opus packet with floating point output.
|
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
|
||||
* @param [in] len <tt>opus_int32</tt>: Number of bytes in payload |
|
||||
* @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length |
|
||||
* is frame_size*channels*sizeof(float) |
|
||||
* @param [in] frame_size Number of samples per channel of available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
|
||||
* not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
|
||||
* then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
|
||||
* FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
|
||||
* decoded. If no such data is available the frame is decoded as if it were lost. |
|
||||
* @returns Number of decoded samples or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float( |
|
||||
OpusDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
float *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Perform a CTL function on an Opus decoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated |
|
||||
* by a convenience macro. |
|
||||
* @param st <tt>OpusDecoder*</tt>: Decoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls or |
|
||||
* @ref opus_decoderctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_decoderctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Frees an <code>OpusDecoder</code> allocated by opus_decoder_create().
|
|
||||
* @param[in] st <tt>OpusDecoder*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st); |
|
||||
|
|
||||
/** Parse an opus packet into one or more frames.
|
|
||||
* Opus_decode will perform this operation internally so most applications do |
|
||||
* not need to use this function. |
|
||||
* This function does not copy the frames, the returned pointers are pointers into |
|
||||
* the input packet. |
|
||||
* @param [in] data <tt>char*</tt>: Opus packet to be parsed |
|
||||
* @param [in] len <tt>opus_int32</tt>: size of data |
|
||||
* @param [out] out_toc <tt>char*</tt>: TOC pointer |
|
||||
* @param [out] frames <tt>char*[48]</tt> encapsulated frames |
|
||||
* @param [out] size <tt>opus_int16[48]</tt> sizes of the encapsulated frames |
|
||||
* @param [out] payload_offset <tt>int*</tt>: returns the position of the payload within the packet (in bytes) |
|
||||
* @returns number of frames |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_packet_parse( |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
unsigned char *out_toc, |
|
||||
const unsigned char *frames[48], |
|
||||
opus_int16 size[48], |
|
||||
int *payload_offset |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
/** Gets the bandwidth of an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet |
|
||||
* @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples per frame from an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet. |
|
||||
* This must contain at least one byte of |
|
||||
* data. |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
|
||||
* This must be a multiple of 400, or |
|
||||
* inaccurate results will be returned. |
|
||||
* @returns Number of samples per frame. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of channels from an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet |
|
||||
* @returns Number of channels |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of frames in an Opus packet.
|
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @returns Number of frames |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples of an Opus packet.
|
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
|
||||
* This must be a multiple of 400, or |
|
||||
* inaccurate results will be returned. |
|
||||
* @returns Number of samples |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples of an Opus packet.
|
|
||||
* @param [in] dec <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @returns Number of samples |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
|
||||
|
|
||||
/** Applies soft-clipping to bring a float signal within the [-1,1] range. If
|
|
||||
* the signal is already in that range, nothing is done. If there are values |
|
||||
* outside of [-1,1], then the signal is clipped as smoothly as possible to |
|
||||
* both fit in the range and avoid creating excessive distortion in the |
|
||||
* process. |
|
||||
* @param [in,out] pcm <tt>float*</tt>: Input PCM and modified PCM |
|
||||
* @param [in] frame_size <tt>int</tt> Number of samples per channel to process |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels |
|
||||
* @param [in,out] softclip_mem <tt>float*</tt>: State memory for the soft clipping process (one float per channel, initialized to zero) |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem); |
|
||||
|
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_repacketizer Repacketizer
|
|
||||
* @{ |
|
||||
* |
|
||||
* The repacketizer can be used to merge multiple Opus packets into a single |
|
||||
* packet or alternatively to split Opus packets that have previously been |
|
||||
* merged. Splitting valid Opus packets is always guaranteed to succeed, |
|
||||
* whereas merging valid packets only succeeds if all frames have the same |
|
||||
* mode, bandwidth, and frame size, and when the total duration of the merged |
|
||||
* packet is no more than 120 ms. The 120 ms limit comes from the |
|
||||
* specification and limits decoder memory requirements at a point where |
|
||||
* framing overhead becomes negligible. |
|
||||
* |
|
||||
* The repacketizer currently only operates on elementary Opus |
|
||||
* streams. It will not manipualte multistream packets successfully, except in |
|
||||
* the degenerate case where they consist of data from a single stream. |
|
||||
* |
|
||||
* The repacketizing process starts with creating a repacketizer state, either |
|
||||
* by calling opus_repacketizer_create() or by allocating the memory yourself, |
|
||||
* e.g., |
|
||||
* @code |
|
||||
* OpusRepacketizer *rp; |
|
||||
* rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size()); |
|
||||
* if (rp != NULL) |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* @endcode |
|
||||
* |
|
||||
* Then the application should submit packets with opus_repacketizer_cat(), |
|
||||
* extract new packets with opus_repacketizer_out() or |
|
||||
* opus_repacketizer_out_range(), and then reset the state for the next set of |
|
||||
* input packets via opus_repacketizer_init(). |
|
||||
* |
|
||||
* For example, to split a sequence of packets into individual frames: |
|
||||
* @code |
|
||||
* unsigned char *data; |
|
||||
* int len; |
|
||||
* while (get_next_packet(&data, &len)) |
|
||||
* { |
|
||||
* unsigned char out[1276]; |
|
||||
* opus_int32 out_len; |
|
||||
* int nb_frames; |
|
||||
* int err; |
|
||||
* int i; |
|
||||
* err = opus_repacketizer_cat(rp, data, len); |
|
||||
* if (err != OPUS_OK) |
|
||||
* { |
|
||||
* release_packet(data); |
|
||||
* return err; |
|
||||
* } |
|
||||
* nb_frames = opus_repacketizer_get_nb_frames(rp); |
|
||||
* for (i = 0; i < nb_frames; i++) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out)); |
|
||||
* if (out_len < 0) |
|
||||
* { |
|
||||
* release_packet(data); |
|
||||
* return (int)out_len; |
|
||||
* } |
|
||||
* output_next_packet(out, out_len); |
|
||||
* } |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* release_packet(data); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* Alternatively, to combine a sequence of frames into packets that each |
|
||||
* contain up to <code>TARGET_DURATION_MS</code> milliseconds of data: |
|
||||
* @code |
|
||||
* // The maximum number of packets with duration TARGET_DURATION_MS occurs
|
|
||||
* // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5)
|
|
||||
* // packets.
|
|
||||
* unsigned char *data[(TARGET_DURATION_MS*2/5)+1]; |
|
||||
* opus_int32 len[(TARGET_DURATION_MS*2/5)+1]; |
|
||||
* int nb_packets; |
|
||||
* unsigned char out[1277*(TARGET_DURATION_MS*2/2)]; |
|
||||
* opus_int32 out_len; |
|
||||
* int prev_toc; |
|
||||
* nb_packets = 0; |
|
||||
* while (get_next_packet(data+nb_packets, len+nb_packets)) |
|
||||
* { |
|
||||
* int nb_frames; |
|
||||
* int err; |
|
||||
* nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]); |
|
||||
* if (nb_frames < 1) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return nb_frames; |
|
||||
* } |
|
||||
* nb_frames += opus_repacketizer_get_nb_frames(rp); |
|
||||
* // If adding the next packet would exceed our target, or it has an
|
|
||||
* // incompatible TOC sequence, output the packets we already have before
|
|
||||
* // submitting it.
|
|
||||
* // N.B., The nb_packets > 0 check ensures we've submitted at least one
|
|
||||
* // packet since the last call to opus_repacketizer_init(). Otherwise a
|
|
||||
* // single packet longer than TARGET_DURATION_MS would cause us to try to
|
|
||||
* // output an (invalid) empty packet. It also ensures that prev_toc has
|
|
||||
* // been set to a valid value. Additionally, len[nb_packets] > 0 is
|
|
||||
* // guaranteed by the call to opus_packet_get_nb_frames() above, so the
|
|
||||
* // reference to data[nb_packets][0] should be valid.
|
|
||||
* if (nb_packets > 0 && ( |
|
||||
* ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) || |
|
||||
* opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames > |
|
||||
* TARGET_DURATION_MS*48)) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
|
||||
* if (out_len < 0) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return (int)out_len; |
|
||||
* } |
|
||||
* output_next_packet(out, out_len); |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* release_packets(data, nb_packets); |
|
||||
* data[0] = data[nb_packets]; |
|
||||
* len[0] = len[nb_packets]; |
|
||||
* nb_packets = 0; |
|
||||
* } |
|
||||
* err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]); |
|
||||
* if (err != OPUS_OK) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return err; |
|
||||
* } |
|
||||
* prev_toc = data[nb_packets][0]; |
|
||||
* nb_packets++; |
|
||||
* } |
|
||||
* // Output the final, partial packet.
|
|
||||
* if (nb_packets > 0) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
|
||||
* release_packets(data, nb_packets); |
|
||||
* if (out_len < 0) |
|
||||
* return (int)out_len; |
|
||||
* output_next_packet(out, out_len); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* An alternate way of merging packets is to simply call opus_repacketizer_cat() |
|
||||
* unconditionally until it fails. At that point, the merged packet can be |
|
||||
* obtained with opus_repacketizer_out() and the input packet for which |
|
||||
* opus_repacketizer_cat() needs to be re-added to a newly reinitialized |
|
||||
* repacketizer state. |
|
||||
*/ |
|
||||
|
|
||||
typedef struct OpusRepacketizer OpusRepacketizer; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusRepacketizer</code> structure.
|
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void); |
|
||||
|
|
||||
/** (Re)initializes a previously allocated repacketizer state.
|
|
||||
* The state must be at least the size returned by opus_repacketizer_get_size(). |
|
||||
* This can be used for applications which use their own allocator instead of |
|
||||
* malloc(). |
|
||||
* It must also be called to reset the queue of packets waiting to be |
|
||||
* repacketized, which is necessary if the maximum packet duration of 120 ms |
|
||||
* is reached or if you wish to submit packets with a different Opus |
|
||||
* configuration (coding mode, audio bandwidth, frame size, or channel count). |
|
||||
* Failure to do so will prevent a new packet from being added with |
|
||||
* opus_repacketizer_cat(). |
|
||||
* @see opus_repacketizer_create |
|
||||
* @see opus_repacketizer_get_size |
|
||||
* @see opus_repacketizer_cat |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to |
|
||||
* (re)initialize. |
|
||||
* @returns A pointer to the same repacketizer state that was passed in. |
|
||||
*/ |
|
||||
OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Allocates memory and initializes the new repacketizer with
|
|
||||
* opus_repacketizer_init(). |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void); |
|
||||
|
|
||||
/** Frees an <code>OpusRepacketizer</code> allocated by
|
|
||||
* opus_repacketizer_create(). |
|
||||
* @param[in] rp <tt>OpusRepacketizer*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp); |
|
||||
|
|
||||
/** Add a packet to the current repacketizer state.
|
|
||||
* This packet must match the configuration of any packets already submitted |
|
||||
* for repacketization since the last call to opus_repacketizer_init(). |
|
||||
* This means that it must have the same coding mode, audio bandwidth, frame |
|
||||
* size, and channel count. |
|
||||
* This can be checked in advance by examining the top 6 bits of the first |
|
||||
* byte of the packet, and ensuring they match the top 6 bits of the first |
|
||||
* byte of any previously submitted packet. |
|
||||
* The total duration of audio in the repacketizer state also must not exceed |
|
||||
* 120 ms, the maximum duration of a single packet, after adding this packet. |
|
||||
* |
|
||||
* The contents of the current repacketizer state can be extracted into new |
|
||||
* packets using opus_repacketizer_out() or opus_repacketizer_out_range(). |
|
||||
* |
|
||||
* In order to add a packet with a different configuration or to add more |
|
||||
* audio beyond 120 ms, you must clear the repacketizer state by calling |
|
||||
* opus_repacketizer_init(). |
|
||||
* If a packet is too large to add to the current repacketizer state, no part |
|
||||
* of it is added, even if it contains multiple frames, some of which might |
|
||||
* fit. |
|
||||
* If you wish to be able to add parts of such packets, you should first use |
|
||||
* another repacketizer to split the packet into pieces and add them |
|
||||
* individually. |
|
||||
* @see opus_repacketizer_out_range |
|
||||
* @see opus_repacketizer_out |
|
||||
* @see opus_repacketizer_init |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to which to |
|
||||
* add the packet. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: The packet data. |
|
||||
* The application must ensure |
|
||||
* this pointer remains valid |
|
||||
* until the next call to |
|
||||
* opus_repacketizer_init() or |
|
||||
* opus_repacketizer_destroy(). |
|
||||
* @param len <tt>opus_int32</tt>: The number of bytes in the packet data. |
|
||||
* @returns An error code indicating whether or not the operation succeeded. |
|
||||
* @retval #OPUS_OK The packet's contents have been added to the repacketizer |
|
||||
* state. |
|
||||
* @retval #OPUS_INVALID_PACKET The packet did not have a valid TOC sequence, |
|
||||
* the packet's TOC sequence was not compatible |
|
||||
* with previously submitted packets (because |
|
||||
* the coding mode, audio bandwidth, frame size, |
|
||||
* or channel count did not match), or adding |
|
||||
* this packet would increase the total amount of |
|
||||
* audio stored in the repacketizer state to more |
|
||||
* than 120 ms. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
|
||||
|
|
||||
|
|
||||
/** Construct a new packet from data previously submitted to the repacketizer
|
|
||||
* state via opus_repacketizer_cat(). |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
|
||||
* construct the new packet. |
|
||||
* @param begin <tt>int</tt>: The index of the first frame in the current |
|
||||
* repacketizer state to include in the output. |
|
||||
* @param end <tt>int</tt>: One past the index of the last frame in the |
|
||||
* current repacketizer state to include in the |
|
||||
* output. |
|
||||
* @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
|
||||
* store the output packet. |
|
||||
* @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
|
||||
* the output buffer. In order to guarantee |
|
||||
* success, this should be at least |
|
||||
* <code>1276</code> for a single frame, |
|
||||
* or for multiple frames, |
|
||||
* <code>1277*(end-begin)</code>. |
|
||||
* However, <code>1*(end-begin)</code> plus |
|
||||
* the size of all packet data submitted to |
|
||||
* the repacketizer since the last call to |
|
||||
* opus_repacketizer_init() or |
|
||||
* opus_repacketizer_create() is also |
|
||||
* sufficient, and possibly much smaller. |
|
||||
* @returns The total size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG <code>[begin,end)</code> was an invalid range of |
|
||||
* frames (begin < 0, begin >= end, or end > |
|
||||
* opus_repacketizer_get_nb_frames()). |
|
||||
* @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
|
||||
* complete output packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Return the total number of frames contained in packet data submitted to
|
|
||||
* the repacketizer state so far via opus_repacketizer_cat() since the last |
|
||||
* call to opus_repacketizer_init() or opus_repacketizer_create(). |
|
||||
* This defines the valid range of packets that can be extracted with |
|
||||
* opus_repacketizer_out_range() or opus_repacketizer_out(). |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state containing the |
|
||||
* frames. |
|
||||
* @returns The total number of frames contained in the packet data submitted |
|
||||
* to the repacketizer state. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Construct a new packet from data previously submitted to the repacketizer
|
|
||||
* state via opus_repacketizer_cat(). |
|
||||
* This is a convenience routine that returns all the data submitted so far |
|
||||
* in a single packet. |
|
||||
* It is equivalent to calling |
|
||||
* @code |
|
||||
* opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp), |
|
||||
* data, maxlen) |
|
||||
* @endcode |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
|
||||
* construct the new packet. |
|
||||
* @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
|
||||
* store the output packet. |
|
||||
* @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
|
||||
* the output buffer. In order to guarantee |
|
||||
* success, this should be at least |
|
||||
* <code>1277*opus_repacketizer_get_nb_frames(rp)</code>. |
|
||||
* However, |
|
||||
* <code>1*opus_repacketizer_get_nb_frames(rp)</code> |
|
||||
* plus the size of all packet data |
|
||||
* submitted to the repacketizer since the |
|
||||
* last call to opus_repacketizer_init() or |
|
||||
* opus_repacketizer_create() is also |
|
||||
* sufficient, and possibly much smaller. |
|
||||
* @returns The total size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
|
||||
* complete output packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Pads a given Opus packet to a larger size (possibly changing the TOC sequence).
|
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to pad. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
|
||||
* This must be at least as large as len. |
|
||||
* @returns an error code |
|
||||
* @retval #OPUS_OK \a on success. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len); |
|
||||
|
|
||||
/** Remove all padding from a given Opus packet and rewrite the TOC sequence to
|
|
||||
* minimize space usage. |
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to strip. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @returns The new size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len); |
|
||||
|
|
||||
/** Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence).
|
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to pad. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
|
||||
* This must be at least 1. |
|
||||
* @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
|
||||
* This must be at least as large as len. |
|
||||
* @returns an error code |
|
||||
* @retval #OPUS_OK \a on success. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams); |
|
||||
|
|
||||
/** Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to
|
|
||||
* minimize space usage. |
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to strip. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
|
||||
* This must be at least 1. |
|
||||
* @returns The new size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_H */ |
|
||||
@ -1,799 +0,0 @@ |
|||||
/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
|
|
||||
Written by Jean-Marc Valin and Koen Vos */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus_defines.h |
|
||||
* @brief Opus reference implementation constants |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_DEFINES_H |
|
||||
#define OPUS_DEFINES_H |
|
||||
|
|
||||
#include "opus_types.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/** @defgroup opus_errorcodes Error codes
|
|
||||
* @{ |
|
||||
*/ |
|
||||
/** No error @hideinitializer*/ |
|
||||
#define OPUS_OK 0 |
|
||||
/** One or more invalid/out of range arguments @hideinitializer*/ |
|
||||
#define OPUS_BAD_ARG -1 |
|
||||
/** Not enough bytes allocated in the buffer @hideinitializer*/ |
|
||||
#define OPUS_BUFFER_TOO_SMALL -2 |
|
||||
/** An internal error was detected @hideinitializer*/ |
|
||||
#define OPUS_INTERNAL_ERROR -3 |
|
||||
/** The compressed data passed is corrupted @hideinitializer*/ |
|
||||
#define OPUS_INVALID_PACKET -4 |
|
||||
/** Invalid/unsupported request number @hideinitializer*/ |
|
||||
#define OPUS_UNIMPLEMENTED -5 |
|
||||
/** An encoder or decoder structure is invalid or already freed @hideinitializer*/ |
|
||||
#define OPUS_INVALID_STATE -6 |
|
||||
/** Memory allocation has failed @hideinitializer*/ |
|
||||
#define OPUS_ALLOC_FAIL -7 |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @cond OPUS_INTERNAL_DOC */ |
|
||||
/**Export control for opus functions */ |
|
||||
|
|
||||
#ifndef OPUS_EXPORT |
|
||||
# if defined(WIN32) |
|
||||
# if defined(OPUS_BUILD) && defined(DLL_EXPORT) |
|
||||
# define OPUS_EXPORT __declspec(dllexport) |
|
||||
# else |
|
||||
# define OPUS_EXPORT |
|
||||
# endif |
|
||||
# elif defined(__GNUC__) && defined(OPUS_BUILD) |
|
||||
# define OPUS_EXPORT __attribute__ ((visibility ("default"))) |
|
||||
# else |
|
||||
# define OPUS_EXPORT |
|
||||
# endif |
|
||||
#endif |
|
||||
|
|
||||
# if !defined(OPUS_GNUC_PREREQ) |
|
||||
# if defined(__GNUC__)&&defined(__GNUC_MINOR__) |
|
||||
# define OPUS_GNUC_PREREQ(_maj,_min) \ |
|
||||
((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) |
|
||||
# else |
|
||||
# define OPUS_GNUC_PREREQ(_maj,_min) 0 |
|
||||
# endif |
|
||||
# endif |
|
||||
|
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
|
||||
# if OPUS_GNUC_PREREQ(3,0) |
|
||||
# define OPUS_RESTRICT __restrict__ |
|
||||
# elif (defined(_MSC_VER) && _MSC_VER >= 1400) |
|
||||
# define OPUS_RESTRICT __restrict |
|
||||
# else |
|
||||
# define OPUS_RESTRICT |
|
||||
# endif |
|
||||
#else |
|
||||
# define OPUS_RESTRICT restrict |
|
||||
#endif |
|
||||
|
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
|
||||
# if OPUS_GNUC_PREREQ(2,7) |
|
||||
# define OPUS_INLINE __inline__ |
|
||||
# elif (defined(_MSC_VER)) |
|
||||
# define OPUS_INLINE __inline |
|
||||
# else |
|
||||
# define OPUS_INLINE |
|
||||
# endif |
|
||||
#else |
|
||||
# define OPUS_INLINE inline |
|
||||
#endif |
|
||||
|
|
||||
/**Warning attributes for opus functions
|
|
||||
* NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out |
|
||||
* some paranoid null checks. */ |
|
||||
#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
|
||||
# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) |
|
||||
#else |
|
||||
# define OPUS_WARN_UNUSED_RESULT |
|
||||
#endif |
|
||||
#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
|
||||
# define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) |
|
||||
#else |
|
||||
# define OPUS_ARG_NONNULL(_x) |
|
||||
#endif |
|
||||
|
|
||||
/** These are the actual Encoder CTL ID numbers.
|
|
||||
* They should not be used directly by applications. |
|
||||
* In general, SETs should be even and GETs should be odd.*/ |
|
||||
#define OPUS_SET_APPLICATION_REQUEST 4000 |
|
||||
#define OPUS_GET_APPLICATION_REQUEST 4001 |
|
||||
#define OPUS_SET_BITRATE_REQUEST 4002 |
|
||||
#define OPUS_GET_BITRATE_REQUEST 4003 |
|
||||
#define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 |
|
||||
#define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 |
|
||||
#define OPUS_SET_VBR_REQUEST 4006 |
|
||||
#define OPUS_GET_VBR_REQUEST 4007 |
|
||||
#define OPUS_SET_BANDWIDTH_REQUEST 4008 |
|
||||
#define OPUS_GET_BANDWIDTH_REQUEST 4009 |
|
||||
#define OPUS_SET_COMPLEXITY_REQUEST 4010 |
|
||||
#define OPUS_GET_COMPLEXITY_REQUEST 4011 |
|
||||
#define OPUS_SET_INBAND_FEC_REQUEST 4012 |
|
||||
#define OPUS_GET_INBAND_FEC_REQUEST 4013 |
|
||||
#define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 |
|
||||
#define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 |
|
||||
#define OPUS_SET_DTX_REQUEST 4016 |
|
||||
#define OPUS_GET_DTX_REQUEST 4017 |
|
||||
#define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 |
|
||||
#define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 |
|
||||
#define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 |
|
||||
#define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 |
|
||||
#define OPUS_SET_SIGNAL_REQUEST 4024 |
|
||||
#define OPUS_GET_SIGNAL_REQUEST 4025 |
|
||||
#define OPUS_GET_LOOKAHEAD_REQUEST 4027 |
|
||||
/* #define OPUS_RESET_STATE 4028 */ |
|
||||
#define OPUS_GET_SAMPLE_RATE_REQUEST 4029 |
|
||||
#define OPUS_GET_FINAL_RANGE_REQUEST 4031 |
|
||||
#define OPUS_GET_PITCH_REQUEST 4033 |
|
||||
#define OPUS_SET_GAIN_REQUEST 4034 |
|
||||
#define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */ |
|
||||
#define OPUS_SET_LSB_DEPTH_REQUEST 4036 |
|
||||
#define OPUS_GET_LSB_DEPTH_REQUEST 4037 |
|
||||
#define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039 |
|
||||
#define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040 |
|
||||
#define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041 |
|
||||
#define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042 |
|
||||
#define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043 |
|
||||
/* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */ |
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046 |
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047 |
|
||||
#define OPUS_GET_IN_DTX_REQUEST 4049 |
|
||||
|
|
||||
/** Defines for the presence of extended APIs. */ |
|
||||
#define OPUS_HAVE_OPUS_PROJECTION_H |
|
||||
|
|
||||
/* Macros to trigger compilation errors when the wrong types are provided to a CTL */ |
|
||||
#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) |
|
||||
#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) |
|
||||
#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) |
|
||||
#define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr))) |
|
||||
/** @endcond */ |
|
||||
|
|
||||
/** @defgroup opus_ctlvalues Pre-defined values for CTL interface
|
|
||||
* @see opus_genericctls, opus_encoderctls |
|
||||
* @{ |
|
||||
*/ |
|
||||
/* Values for the various encoder CTLs */ |
|
||||
#define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/ |
|
||||
#define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/ |
|
||||
|
|
||||
/** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_VOIP 2048 |
|
||||
/** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_AUDIO 2049 |
|
||||
/** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 |
|
||||
|
|
||||
#define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */ |
|
||||
#define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */ |
|
||||
#define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hideinitializer*/ |
|
||||
|
|
||||
#define OPUS_FRAMESIZE_ARG 5000 /**< Select frame size from the argument (default) */ |
|
||||
#define OPUS_FRAMESIZE_2_5_MS 5001 /**< Use 2.5 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_5_MS 5002 /**< Use 5 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_10_MS 5003 /**< Use 10 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_20_MS 5004 /**< Use 20 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_40_MS 5005 /**< Use 40 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_60_MS 5006 /**< Use 60 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_80_MS 5007 /**< Use 80 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_100_MS 5008 /**< Use 100 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_120_MS 5009 /**< Use 120 ms frames */ |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
|
|
||||
/** @defgroup opus_encoderctls Encoder related CTLs
|
|
||||
* |
|
||||
* These are convenience macros for use with the \c opus_encode_ctl |
|
||||
* interface. They are used to generate the appropriate series of |
|
||||
* arguments for that call, passing the correct type, size and so |
|
||||
* on as expected for each particular request. |
|
||||
* |
|
||||
* Some usage examples: |
|
||||
* |
|
||||
* @code |
|
||||
* int ret; |
|
||||
* ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); |
|
||||
* if (ret != OPUS_OK) return ret; |
|
||||
* |
|
||||
* opus_int32 rate; |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); |
|
||||
* |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
|
||||
* @endcode |
|
||||
* |
|
||||
* @see opus_genericctls, opus_encoder |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Configures the encoder's computational complexity.
|
|
||||
* The supported range is 0-10 inclusive with 10 representing the highest complexity. |
|
||||
* @see OPUS_GET_COMPLEXITY |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive. |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's complexity configuration.
|
|
||||
* @see OPUS_SET_COMPLEXITY |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10, |
|
||||
* inclusive. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the bitrate in the encoder.
|
|
||||
* Rates from 500 to 512000 bits per second are meaningful, as well as the |
|
||||
* special values #OPUS_AUTO and #OPUS_BITRATE_MAX. |
|
||||
* The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much |
|
||||
* rate as it can, which is useful for controlling the rate by adjusting the |
|
||||
* output buffer size. |
|
||||
* @see OPUS_GET_BITRATE |
|
||||
* @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default |
|
||||
* is determined based on the number of |
|
||||
* channels and the input sampling rate. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's bitrate configuration.
|
|
||||
* @see OPUS_SET_BITRATE |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second. |
|
||||
* The default is determined based on the |
|
||||
* number of channels and the input |
|
||||
* sampling rate. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Enables or disables variable bitrate (VBR) in the encoder.
|
|
||||
* The configured bitrate may not be met exactly because frames must |
|
||||
* be an integer number of bytes in length. |
|
||||
* @see OPUS_GET_VBR |
|
||||
* @see OPUS_SET_VBR_CONSTRAINT |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can |
|
||||
* cause noticeable quality degradation.</dd> |
|
||||
* <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by |
|
||||
* #OPUS_SET_VBR_CONSTRAINT.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) |
|
||||
/** Determine if variable bitrate (VBR) is enabled in the encoder.
|
|
||||
* @see OPUS_SET_VBR |
|
||||
* @see OPUS_GET_VBR_CONSTRAINT |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Hard CBR.</dd> |
|
||||
* <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via |
|
||||
* #OPUS_GET_VBR_CONSTRAINT.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Enables or disables constrained VBR in the encoder.
|
|
||||
* This setting is ignored when the encoder is in CBR mode. |
|
||||
* @warning Only the MDCT mode of Opus currently heeds the constraint. |
|
||||
* Speech mode ignores it completely, hybrid mode may fail to obey it |
|
||||
* if the LPC layer uses more bitrate than the constraint would have |
|
||||
* permitted. |
|
||||
* @see OPUS_GET_VBR_CONSTRAINT |
|
||||
* @see OPUS_SET_VBR |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Unconstrained VBR.</dd> |
|
||||
* <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one |
|
||||
* frame of buffering delay assuming a transport with a |
|
||||
* serialization speed of the nominal bitrate.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x) |
|
||||
/** Determine if constrained VBR is enabled in the encoder.
|
|
||||
* @see OPUS_SET_VBR_CONSTRAINT |
|
||||
* @see OPUS_GET_VBR |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Unconstrained VBR.</dd> |
|
||||
* <dt>1</dt><dd>Constrained VBR (default).</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures mono/stereo forcing in the encoder.
|
|
||||
* This can force the encoder to produce packets encoded as either mono or |
|
||||
* stereo, regardless of the format of the input audio. This is useful when |
|
||||
* the caller knows that the input signal is currently a mono source embedded |
|
||||
* in a stereo stream. |
|
||||
* @see OPUS_GET_FORCE_CHANNELS |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
|
||||
* <dt>1</dt> <dd>Forced mono</dd> |
|
||||
* <dt>2</dt> <dd>Forced stereo</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's forced channel configuration.
|
|
||||
* @see OPUS_SET_FORCE_CHANNELS |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
|
||||
* <dt>1</dt> <dd>Forced mono</dd> |
|
||||
* <dt>2</dt> <dd>Forced stereo</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the maximum bandpass that the encoder will select automatically.
|
|
||||
* Applications should normally use this instead of #OPUS_SET_BANDWIDTH |
|
||||
* (leaving that set to the default, #OPUS_AUTO). This allows the |
|
||||
* application to set an upper bound based on the type of input it is |
|
||||
* providing, but still gives the encoder the freedom to reduce the bandpass |
|
||||
* when the bitrate becomes too low, for better overall quality. |
|
||||
* @see OPUS_GET_MAX_BANDWIDTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x) |
|
||||
|
|
||||
/** Gets the encoder's configured maximum allowed bandpass.
|
|
||||
* @see OPUS_SET_MAX_BANDWIDTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Sets the encoder's bandpass to a specific value.
|
|
||||
* This prevents the encoder from automatically selecting the bandpass based |
|
||||
* on the available bitrate. If an application knows the bandpass of the input |
|
||||
* audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH |
|
||||
* instead, which still gives the encoder the freedom to reduce the bandpass |
|
||||
* when the bitrate becomes too low, for better overall quality. |
|
||||
* @see OPUS_GET_BANDWIDTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) |
|
||||
|
|
||||
/** Configures the type of signal being encoded.
|
|
||||
* This is a hint which helps the encoder's mode selection. |
|
||||
* @see OPUS_GET_SIGNAL |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
|
||||
* <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured signal type.
|
|
||||
* @see OPUS_SET_SIGNAL |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
|
||||
* <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
|
|
||||
/** Configures the encoder's intended application.
|
|
||||
* The initial value is a mandatory argument to the encoder_create function. |
|
||||
* @see OPUS_GET_APPLICATION |
|
||||
* @param[in] x <tt>opus_int32</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured application.
|
|
||||
* @see OPUS_SET_APPLICATION |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the total samples of delay added by the entire codec.
|
|
||||
* This can be queried by the encoder and then the provided number of samples can be |
|
||||
* skipped on from the start of the decoder's output to provide time aligned input |
|
||||
* and output. From the perspective of a decoding application the real data begins this many |
|
||||
* samples late. |
|
||||
* |
|
||||
* The decoder contribution to this delay is identical for all decoders, but the |
|
||||
* encoder portion of the delay may vary from implementation to implementation, |
|
||||
* version to version, or even depend on the encoder's initial configuration. |
|
||||
* Applications needing delay compensation should call this CTL rather than |
|
||||
* hard-coding a value. |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of inband forward error correction (FEC).
|
|
||||
* @note This is only applicable to the LPC layer |
|
||||
* @see OPUS_GET_INBAND_FEC |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Disable inband FEC (default).</dd> |
|
||||
* <dt>1</dt><dd>Enable inband FEC.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) |
|
||||
/** Gets encoder's configured use of inband forward error correction.
|
|
||||
* @see OPUS_SET_INBAND_FEC |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Inband FEC disabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Inband FEC enabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's expected packet loss percentage.
|
|
||||
* Higher values trigger progressively more loss resistant behavior in the encoder |
|
||||
* at the expense of quality at a given bitrate in the absence of packet loss, but |
|
||||
* greater quality under loss. |
|
||||
* @see OPUS_GET_PACKET_LOSS_PERC |
|
||||
* @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured packet loss percentage.
|
|
||||
* @see OPUS_SET_PACKET_LOSS_PERC |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage |
|
||||
* in the range 0-100, inclusive (default: 0). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of discontinuous transmission (DTX).
|
|
||||
* @note This is only applicable to the LPC layer |
|
||||
* @see OPUS_GET_DTX |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Disable DTX (default).</dd> |
|
||||
* <dt>1</dt><dd>Enabled DTX.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) |
|
||||
/** Gets encoder's configured use of discontinuous transmission.
|
|
||||
* @see OPUS_SET_DTX |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>DTX disabled (default).</dd> |
|
||||
* <dt>1</dt><dd>DTX enabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) |
|
||||
/** Configures the depth of signal being encoded.
|
|
||||
* |
|
||||
* This is a hint which helps the encoder identify silence and near-silence. |
|
||||
* It represents the number of significant bits of linear intensity below |
|
||||
* which the signal contains ignorable quantization or other noise. |
|
||||
* |
|
||||
* For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting |
|
||||
* for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate |
|
||||
* for 16-bit linear pcm input with opus_encode_float(). |
|
||||
* |
|
||||
* When using opus_encode() instead of opus_encode_float(), or when libopus |
|
||||
* is compiled for fixed-point, the encoder uses the minimum of the value |
|
||||
* set here and the value 16. |
|
||||
* |
|
||||
* @see OPUS_GET_LSB_DEPTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24 |
|
||||
* (default: 24). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured signal depth.
|
|
||||
* @see OPUS_SET_LSB_DEPTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and |
|
||||
* 24 (default: 24). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of variable duration frames.
|
|
||||
* When variable duration is enabled, the encoder is free to use a shorter frame |
|
||||
* size than the one requested in the opus_encode*() call. |
|
||||
* It is then the user's responsibility |
|
||||
* to verify how much audio was encoded by checking the ToC byte of the encoded |
|
||||
* packet. The part of the audio that was not encoded needs to be resent to the |
|
||||
* encoder for the next call. Do not use this option unless you <b>really</b> |
|
||||
* know what you are doing. |
|
||||
* @see OPUS_GET_EXPERT_FRAME_DURATION |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured use of variable duration frames.
|
|
||||
* @see OPUS_SET_EXPERT_FRAME_DURATION |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** If set to 1, disables almost all use of prediction, making frames almost
|
|
||||
* completely independent. This reduces quality. |
|
||||
* @see OPUS_GET_PREDICTION_DISABLED |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Enable prediction (default).</dd> |
|
||||
* <dt>1</dt><dd>Disable prediction.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured prediction status.
|
|
||||
* @see OPUS_SET_PREDICTION_DISABLED |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Prediction enabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Prediction disabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_genericctls Generic CTLs
|
|
||||
* |
|
||||
* These macros are used with the \c opus_decoder_ctl and |
|
||||
* \c opus_encoder_ctl calls to generate a particular |
|
||||
* request. |
|
||||
* |
|
||||
* When called on an \c OpusDecoder they apply to that |
|
||||
* particular decoder instance. When called on an |
|
||||
* \c OpusEncoder they apply to the corresponding setting |
|
||||
* on that encoder instance, if present. |
|
||||
* |
|
||||
* Some usage examples: |
|
||||
* |
|
||||
* @code |
|
||||
* int ret; |
|
||||
* opus_int32 pitch; |
|
||||
* ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); |
|
||||
* if (ret == OPUS_OK) return ret; |
|
||||
* |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
|
||||
* opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); |
|
||||
* |
|
||||
* opus_int32 enc_bw, dec_bw; |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); |
|
||||
* opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); |
|
||||
* if (enc_bw != dec_bw) { |
|
||||
* printf("packet bandwidth mismatch!\n"); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Resets the codec state to be equivalent to a freshly initialized state.
|
|
||||
* This should be called when switching streams in order to prevent |
|
||||
* the back to back decoding from giving different results from |
|
||||
* one at a time decoding. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_RESET_STATE 4028 |
|
||||
|
|
||||
/** Gets the final state of the codec's entropy coder.
|
|
||||
* This is used for testing purposes, |
|
||||
* The encoder and decoder state should be identical after coding a payload |
|
||||
* (assuming no data corruption or software bugs) |
|
||||
* |
|
||||
* @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) |
|
||||
|
|
||||
/** Gets the encoder's configured bandpass or the decoder's last bandpass.
|
|
||||
* @see OPUS_SET_BANDWIDTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the sampling rate the encoder or decoder was initialized with.
|
|
||||
* This simply returns the <code>Fs</code> value passed to opus_encoder_init() |
|
||||
* or opus_decoder_init(). |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** If set to 1, disables the use of phase inversion for intensity stereo,
|
|
||||
* improving the quality of mono downmixes, but slightly reducing normal |
|
||||
* stereo quality. Disabling phase inversion in the decoder does not comply |
|
||||
* with RFC 6716, although it does not cause any interoperability issue and |
|
||||
* is expected to become part of the Opus standard once RFC 6716 is updated |
|
||||
* by draft-ietf-codec-opus-update. |
|
||||
* @see OPUS_GET_PHASE_INVERSION_DISABLED |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Enable phase inversion (default).</dd> |
|
||||
* <dt>1</dt><dd>Disable phase inversion.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured phase inversion status.
|
|
||||
* @see OPUS_SET_PHASE_INVERSION_DISABLED |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Stereo phase inversion enabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Stereo phase inversion disabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
|
||||
/** Gets the DTX state of the encoder.
|
|
||||
* Returns whether the last encoded frame was either a comfort noise update |
|
||||
* during DTX or not encoded because of DTX. |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>The encoder is not in DTX.</dd> |
|
||||
* <dt>1</dt><dd>The encoder is in DTX.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_IN_DTX(x) OPUS_GET_IN_DTX_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_decoderctls Decoder related CTLs
|
|
||||
* @see opus_genericctls, opus_encoderctls, opus_decoder |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Configures decoder gain adjustment.
|
|
||||
* Scales the decoded output by a factor specified in Q8 dB units. |
|
||||
* This has a maximum range of -32768 to 32767 inclusive, and returns |
|
||||
* OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. |
|
||||
* This setting survives decoder reset. |
|
||||
* |
|
||||
* gain = pow(10, x/(20.0*256)) |
|
||||
* |
|
||||
* @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN
|
|
||||
* |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the duration (in samples) of the last packet successfully decoded or concealed.
|
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the pitch of the last decoded frame, if available.
|
|
||||
* This can be used for any post-processing algorithm requiring the use of pitch, |
|
||||
* e.g. time stretching/shortening. If the last frame was not voiced, or if the |
|
||||
* pitch was not coded in the frame, then zero is returned. |
|
||||
* |
|
||||
* This CTL is only implemented for decoder instances. |
|
||||
* |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available) |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_libinfo Opus library information functions
|
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Converts an opus error code into a human readable string.
|
|
||||
* |
|
||||
* @param[in] error <tt>int</tt>: Error number |
|
||||
* @returns Error string |
|
||||
*/ |
|
||||
OPUS_EXPORT const char *opus_strerror(int error); |
|
||||
|
|
||||
/** Gets the libopus version string.
|
|
||||
* |
|
||||
* Applications may look for the substring "-fixed" in the version string to |
|
||||
* determine whether they have a fixed-point or floating-point build at |
|
||||
* runtime. |
|
||||
* |
|
||||
* @returns Version string |
|
||||
*/ |
|
||||
OPUS_EXPORT const char *opus_get_version_string(void); |
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_DEFINES_H */ |
|
||||
@ -1,660 +0,0 @@ |
|||||
/* Copyright (c) 2011 Xiph.Org Foundation
|
|
||||
Written by Jean-Marc Valin */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus_multistream.h |
|
||||
* @brief Opus reference implementation multistream API |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_MULTISTREAM_H |
|
||||
#define OPUS_MULTISTREAM_H |
|
||||
|
|
||||
#include "opus.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/** @cond OPUS_INTERNAL_DOC */ |
|
||||
|
|
||||
/** Macros to trigger compilation errors when the wrong types are provided to a
|
|
||||
* CTL. */ |
|
||||
/**@{*/ |
|
||||
#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr))) |
|
||||
#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr))) |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** These are the actual encoder and decoder CTL ID numbers.
|
|
||||
* They should not be used directly by applications. |
|
||||
* In general, SETs should be even and GETs should be odd.*/ |
|
||||
/**@{*/ |
|
||||
#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120 |
|
||||
#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122 |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @endcond */ |
|
||||
|
|
||||
/** @defgroup opus_multistream_ctls Multistream specific encoder and decoder CTLs
|
|
||||
* |
|
||||
* These are convenience macros that are specific to the |
|
||||
* opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl() |
|
||||
* interface. |
|
||||
* The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and |
|
||||
* @ref opus_decoderctls may be applied to a multistream encoder or decoder as |
|
||||
* well. |
|
||||
* In addition, you may retrieve the encoder or decoder state for an specific |
|
||||
* stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or |
|
||||
* #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually. |
|
||||
*/ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the encoder state for an individual stream of a multistream encoder.
|
|
||||
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose encoder you |
|
||||
* wish to retrieve. |
|
||||
* This must be non-negative and less than |
|
||||
* the <code>streams</code> parameter used |
|
||||
* to initialize the encoder. |
|
||||
* @param[out] y <tt>OpusEncoder**</tt>: Returns a pointer to the given |
|
||||
* encoder state. |
|
||||
* @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y) |
|
||||
|
|
||||
/** Gets the decoder state for an individual stream of a multistream decoder.
|
|
||||
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose decoder you |
|
||||
* wish to retrieve. |
|
||||
* This must be non-negative and less than |
|
||||
* the <code>streams</code> parameter used |
|
||||
* to initialize the decoder. |
|
||||
* @param[out] y <tt>OpusDecoder**</tt>: Returns a pointer to the given |
|
||||
* decoder state. |
|
||||
* @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_multistream Opus Multistream API
|
|
||||
* @{ |
|
||||
* |
|
||||
* The multistream API allows individual Opus streams to be combined into a |
|
||||
* single packet, enabling support for up to 255 channels. Unlike an |
|
||||
* elementary Opus stream, the encoder and decoder must negotiate the channel |
|
||||
* configuration before the decoder can successfully interpret the data in the |
|
||||
* packets produced by the encoder. Some basic information, such as packet |
|
||||
* duration, can be computed without any special negotiation. |
|
||||
* |
|
||||
* The format for multistream Opus packets is defined in |
|
||||
* <a href="https://tools.ietf.org/html/rfc7845">RFC 7845</a> |
|
||||
* and is based on the self-delimited Opus framing described in Appendix B of |
|
||||
* <a href="https://tools.ietf.org/html/rfc6716">RFC 6716</a>. |
|
||||
* Normal Opus packets are just a degenerate case of multistream Opus packets, |
|
||||
* and can be encoded or decoded with the multistream API by setting |
|
||||
* <code>streams</code> to <code>1</code> when initializing the encoder or |
|
||||
* decoder. |
|
||||
* |
|
||||
* Multistream Opus streams can contain up to 255 elementary Opus streams. |
|
||||
* These may be either "uncoupled" or "coupled", indicating that the decoder |
|
||||
* is configured to decode them to either 1 or 2 channels, respectively. |
|
||||
* The streams are ordered so that all coupled streams appear at the |
|
||||
* beginning. |
|
||||
* |
|
||||
* A <code>mapping</code> table defines which decoded channel <code>i</code> |
|
||||
* should be used for each input/output (I/O) channel <code>j</code>. This table is |
|
||||
* typically provided as an unsigned char array. |
|
||||
* Let <code>i = mapping[j]</code> be the index for I/O channel <code>j</code>. |
|
||||
* If <code>i < 2*coupled_streams</code>, then I/O channel <code>j</code> is |
|
||||
* encoded as the left channel of stream <code>(i/2)</code> if <code>i</code> |
|
||||
* is even, or as the right channel of stream <code>(i/2)</code> if |
|
||||
* <code>i</code> is odd. Otherwise, I/O channel <code>j</code> is encoded as |
|
||||
* mono in stream <code>(i - coupled_streams)</code>, unless it has the special |
|
||||
* value 255, in which case it is omitted from the encoding entirely (the |
|
||||
* decoder will reproduce it as silence). Each value <code>i</code> must either |
|
||||
* be the special value 255 or be less than <code>streams + coupled_streams</code>. |
|
||||
* |
|
||||
* The output channels specified by the encoder |
|
||||
* should use the |
|
||||
* <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis |
|
||||
* channel ordering</a>. A decoder may wish to apply an additional permutation |
|
||||
* to the mapping the encoder used to achieve a different output channel |
|
||||
* order (e.g. for outputing in WAV order). |
|
||||
* |
|
||||
* Each multistream packet contains an Opus packet for each stream, and all of |
|
||||
* the Opus packets in a single multistream packet must have the same |
|
||||
* duration. Therefore the duration of a multistream packet can be extracted |
|
||||
* from the TOC sequence of the first stream, which is located at the |
|
||||
* beginning of the packet, just like an elementary Opus stream: |
|
||||
* |
|
||||
* @code |
|
||||
* int nb_samples; |
|
||||
* int nb_frames; |
|
||||
* nb_frames = opus_packet_get_nb_frames(data, len); |
|
||||
* if (nb_frames < 1) |
|
||||
* return nb_frames; |
|
||||
* nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames; |
|
||||
* @endcode |
|
||||
* |
|
||||
* The general encoding and decoding process proceeds exactly the same as in |
|
||||
* the normal @ref opus_encoder and @ref opus_decoder APIs. |
|
||||
* See their documentation for an overview of how to use the corresponding |
|
||||
* multistream functions. |
|
||||
*/ |
|
||||
|
|
||||
/** Opus multistream encoder state.
|
|
||||
* This contains the complete state of a multistream Opus encoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_multistream_encoder_create |
|
||||
* @see opus_multistream_encoder_init |
|
||||
*/ |
|
||||
typedef struct OpusMSEncoder OpusMSEncoder; |
|
||||
|
|
||||
/** Opus multistream decoder state.
|
|
||||
* This contains the complete state of a multistream Opus decoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_multistream_decoder_create |
|
||||
* @see opus_multistream_decoder_init |
|
||||
*/ |
|
||||
typedef struct OpusMSDecoder OpusMSDecoder; |
|
||||
|
|
||||
/**\name Multistream encoder functions */ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the size of an OpusMSEncoder structure.
|
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @returns The size in bytes on success, or a negative error code |
|
||||
* (see @ref opus_errorcodes) on error. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size( |
|
||||
int streams, |
|
||||
int coupled_streams |
|
||||
); |
|
||||
|
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size( |
|
||||
int channels, |
|
||||
int mapping_family |
|
||||
); |
|
||||
|
|
||||
|
|
||||
/** Allocates and initializes a multistream encoder state.
|
|
||||
* Call opus_multistream_encoder_destroy() to release |
|
||||
* this object when finished. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels in the input signal. |
|
||||
* This must be at most 255. |
|
||||
* It may be greater than the number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than the number of channels. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than the number of input channels. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* encoded channels to input channels, as described in |
|
||||
* @ref opus_multistream. As an extra constraint, the |
|
||||
* multistream encoder does not allow encoding coupled |
|
||||
* streams for which one channel is unused since this |
|
||||
* is never a good idea. |
|
||||
* @param application <tt>int</tt>: The target encoder application. |
|
||||
* This must be one of the following: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
|
||||
* code (see @ref opus_errorcodes) on |
|
||||
* failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int application, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_surround_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int mapping_family, |
|
||||
int *streams, |
|
||||
int *coupled_streams, |
|
||||
unsigned char *mapping, |
|
||||
int application, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
/** Initialize a previously allocated multistream encoder state.
|
|
||||
* The memory pointed to by \a st must be at least the size returned by |
|
||||
* opus_multistream_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of |
|
||||
* malloc. |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @see opus_multistream_encoder_create |
|
||||
* @see opus_multistream_encoder_get_size |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels in the input signal. |
|
||||
* This must be at most 255. |
|
||||
* It may be greater than the number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than the number of channels. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than the number of input channels. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* encoded channels to input channels, as described in |
|
||||
* @ref opus_multistream. As an extra constraint, the |
|
||||
* multistream encoder does not allow encoding coupled |
|
||||
* streams for which one channel is unused since this |
|
||||
* is never a good idea. |
|
||||
* @param application <tt>int</tt>: The target encoder application. |
|
||||
* This must be one of the following: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
|
||||
* on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_encoder_init( |
|
||||
OpusMSEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
OPUS_EXPORT int opus_multistream_surround_encoder_init( |
|
||||
OpusMSEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int mapping_family, |
|
||||
int *streams, |
|
||||
int *coupled_streams, |
|
||||
unsigned char *mapping, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6) OPUS_ARG_NONNULL(7); |
|
||||
|
|
||||
/** Encodes a multistream Opus frame.
|
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved |
|
||||
* samples. |
|
||||
* This must contain |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: Number of samples per channel in the input |
|
||||
* signal. |
|
||||
* This must be an Opus frame size for the |
|
||||
* encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted values |
|
||||
* are 120, 240, 480, 960, 1920, and 2880. |
|
||||
* Passing in a duration of less than 10 ms |
|
||||
* (480 samples at 48 kHz) will prevent the |
|
||||
* encoder from using the LPC or hybrid modes. |
|
||||
* @param[out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode( |
|
||||
OpusMSEncoder *st, |
|
||||
const opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Encodes a multistream Opus frame from floating point input.
|
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param[in] pcm <tt>const float*</tt>: The input signal as interleaved |
|
||||
* samples with a normal range of |
|
||||
* +/-1.0. |
|
||||
* Samples with a range beyond +/-1.0 |
|
||||
* are supported but will be clipped by |
|
||||
* decoders using the integer API and |
|
||||
* should only be used if it is known |
|
||||
* that the far end supports extended |
|
||||
* dynamic range. |
|
||||
* This must contain |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: Number of samples per channel in the input |
|
||||
* signal. |
|
||||
* This must be an Opus frame size for the |
|
||||
* encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted values |
|
||||
* are 120, 240, 480, 960, 1920, and 2880. |
|
||||
* Passing in a duration of less than 10 ms |
|
||||
* (480 samples at 48 kHz) will prevent the |
|
||||
* encoder from using the LPC or hybrid modes. |
|
||||
* @param[out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float( |
|
||||
OpusMSEncoder *st, |
|
||||
const float *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Frees an <code>OpusMSEncoder</code> allocated by
|
|
||||
* opus_multistream_encoder_create(). |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st); |
|
||||
|
|
||||
/** Perform a CTL function on a multistream Opus encoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated by a |
|
||||
* convenience macro. |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls, |
|
||||
* @ref opus_encoderctls, or @ref opus_multistream_ctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_encoderctls |
|
||||
* @see opus_multistream_ctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/**\name Multistream decoder functions */ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the size of an <code>OpusMSDecoder</code> structure.
|
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @returns The size in bytes on success, or a negative error code |
|
||||
* (see @ref opus_errorcodes) on error. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size( |
|
||||
int streams, |
|
||||
int coupled_streams |
|
||||
); |
|
||||
|
|
||||
/** Allocates and initializes a multistream decoder state.
|
|
||||
* Call opus_multistream_decoder_destroy() to release |
|
||||
* this object when finished. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels to output. |
|
||||
* This must be at most 255. |
|
||||
* It may be different from the number of coded |
|
||||
* channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* coded channels to output channels, as described in |
|
||||
* @ref opus_multistream. |
|
||||
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
|
||||
* code (see @ref opus_errorcodes) on |
|
||||
* failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
/** Intialize a previously allocated decoder state object.
|
|
||||
* The memory pointed to by \a st must be at least the size returned by |
|
||||
* opus_multistream_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of |
|
||||
* malloc. |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @see opus_multistream_decoder_create |
|
||||
* @see opus_multistream_deocder_get_size |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels to output. |
|
||||
* This must be at most 255. |
|
||||
* It may be different from the number of coded |
|
||||
* channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* coded channels to output channels, as described in |
|
||||
* @ref opus_multistream. |
|
||||
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
|
||||
* on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_decoder_init( |
|
||||
OpusMSDecoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
/** Decode a multistream Opus packet.
|
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: Input payload. |
|
||||
* Use a <code>NULL</code> |
|
||||
* pointer to indicate packet |
|
||||
* loss. |
|
||||
* @param len <tt>opus_int32</tt>: Number of bytes in payload. |
|
||||
* @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
|
||||
* samples. |
|
||||
* This must contain room for |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: The number of samples per channel of |
|
||||
* available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration |
|
||||
* (120 ms; 5760 for 48kHz), this function will not be capable |
|
||||
* of decoding some packets. In the case of PLC (data==NULL) |
|
||||
* or FEC (decode_fec=1), then frame_size needs to be exactly |
|
||||
* the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the |
|
||||
* next incoming packet. For the PLC and FEC cases, frame_size |
|
||||
* <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
|
||||
* forward error correction data be decoded. |
|
||||
* If no such data is available, the frame is |
|
||||
* decoded as if it were lost. |
|
||||
* @returns Number of samples decoded on success or a negative error code |
|
||||
* (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode( |
|
||||
OpusMSDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Decode a multistream Opus packet with floating point output.
|
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: Input payload. |
|
||||
* Use a <code>NULL</code> |
|
||||
* pointer to indicate packet |
|
||||
* loss. |
|
||||
* @param len <tt>opus_int32</tt>: Number of bytes in payload. |
|
||||
* @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
|
||||
* samples. |
|
||||
* This must contain room for |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: The number of samples per channel of |
|
||||
* available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration |
|
||||
* (120 ms; 5760 for 48kHz), this function will not be capable |
|
||||
* of decoding some packets. In the case of PLC (data==NULL) |
|
||||
* or FEC (decode_fec=1), then frame_size needs to be exactly |
|
||||
* the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the |
|
||||
* next incoming packet. For the PLC and FEC cases, frame_size |
|
||||
* <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
|
||||
* forward error correction data be decoded. |
|
||||
* If no such data is available, the frame is |
|
||||
* decoded as if it were lost. |
|
||||
* @returns Number of samples decoded on success or a negative error code |
|
||||
* (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float( |
|
||||
OpusMSDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
float *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Perform a CTL function on a multistream Opus decoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated by a |
|
||||
* convenience macro. |
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls, |
|
||||
* @ref opus_decoderctls, or @ref opus_multistream_ctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_decoderctls |
|
||||
* @see opus_multistream_ctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Frees an <code>OpusMSDecoder</code> allocated by
|
|
||||
* opus_multistream_decoder_create(). |
|
||||
* @param st <tt>OpusMSDecoder</tt>: Multistream decoder state to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_MULTISTREAM_H */ |
|
||||
@ -1,36 +0,0 @@ |
|||||
//
|
|
||||
// opus_swift.h
|
|
||||
// opus-swift
|
|
||||
//
|
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology
|
|
||||
//
|
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||
// in the Software without restriction, including without limitation the rights
|
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||
// furnished to do so, subject to the following conditions:
|
|
||||
//
|
|
||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||
// copies or substantial portions of the Software.
|
|
||||
//
|
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||
// SOFTWARE.
|
|
||||
//
|
|
||||
|
|
||||
#include <TargetConditionals.h> |
|
||||
|
|
||||
#if TARGET_OS_IPHONE |
|
||||
@import UIKit; |
|
||||
#else |
|
||||
@import AppKit; |
|
||||
#endif |
|
||||
|
|
||||
#include "opus.h" |
|
||||
#include "opus_multistream.h" |
|
||||
|
|
||||
@ -1,166 +0,0 @@ |
|||||
/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */ |
|
||||
/* Modified by Jean-Marc Valin */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
/* opus_types.h based on ogg_types.h from libogg */ |
|
||||
|
|
||||
/**
|
|
||||
@file opus_types.h |
|
||||
@brief Opus reference implementation types |
|
||||
*/ |
|
||||
#ifndef OPUS_TYPES_H |
|
||||
#define OPUS_TYPES_H |
|
||||
|
|
||||
#define opus_int int /* used for counters etc; at least 16 bits */ |
|
||||
#define opus_int64 long long |
|
||||
#define opus_int8 signed char |
|
||||
|
|
||||
#define opus_uint unsigned int /* used for counters etc; at least 16 bits */ |
|
||||
#define opus_uint64 unsigned long long |
|
||||
#define opus_uint8 unsigned char |
|
||||
|
|
||||
/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ |
|
||||
#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) |
|
||||
#include <stdint.h> |
|
||||
# undef opus_int64 |
|
||||
# undef opus_int8 |
|
||||
# undef opus_uint64 |
|
||||
# undef opus_uint8 |
|
||||
typedef int8_t opus_int8; |
|
||||
typedef uint8_t opus_uint8; |
|
||||
typedef int16_t opus_int16; |
|
||||
typedef uint16_t opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef uint32_t opus_uint32; |
|
||||
typedef int64_t opus_int64; |
|
||||
typedef uint64_t opus_uint64; |
|
||||
#elif defined(_WIN32) |
|
||||
|
|
||||
# if defined(__CYGWIN__) |
|
||||
# include <_G_config.h> |
|
||||
typedef _G_int32_t opus_int32; |
|
||||
typedef _G_uint32_t opus_uint32; |
|
||||
typedef _G_int16 opus_int16; |
|
||||
typedef _G_uint16 opus_uint16; |
|
||||
# elif defined(__MINGW32__) |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
# elif defined(__MWERKS__) |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
# else |
|
||||
/* MSVC/Borland */ |
|
||||
typedef __int32 opus_int32; |
|
||||
typedef unsigned __int32 opus_uint32; |
|
||||
typedef __int16 opus_int16; |
|
||||
typedef unsigned __int16 opus_uint16; |
|
||||
# endif |
|
||||
|
|
||||
#elif defined(__MACOS__) |
|
||||
|
|
||||
# include <sys/types.h> |
|
||||
typedef SInt16 opus_int16; |
|
||||
typedef UInt16 opus_uint16; |
|
||||
typedef SInt32 opus_int32; |
|
||||
typedef UInt32 opus_uint32; |
|
||||
|
|
||||
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ |
|
||||
|
|
||||
# include <sys/types.h> |
|
||||
typedef int16_t opus_int16; |
|
||||
typedef u_int16_t opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef u_int32_t opus_uint32; |
|
||||
|
|
||||
#elif defined(__BEOS__) |
|
||||
|
|
||||
/* Be */ |
|
||||
# include <inttypes.h> |
|
||||
typedef int16 opus_int16; |
|
||||
typedef u_int16 opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef u_int32_t opus_uint32; |
|
||||
|
|
||||
#elif defined (__EMX__) |
|
||||
|
|
||||
/* OS/2 GCC */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined (DJGPP) |
|
||||
|
|
||||
/* DJGPP */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined(R5900) |
|
||||
|
|
||||
/* PS2 EE */ |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned opus_uint32; |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
|
|
||||
#elif defined(__SYMBIAN32__) |
|
||||
|
|
||||
/* Symbian GCC */ |
|
||||
typedef signed short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef signed int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) |
|
||||
|
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef long opus_int32; |
|
||||
typedef unsigned long opus_uint32; |
|
||||
|
|
||||
#elif defined(CONFIG_TI_C6X) |
|
||||
|
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#else |
|
||||
|
|
||||
/* Give up, take a reasonable guess */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_TYPES_H */ |
|
||||
Binary file not shown.
@ -1,29 +0,0 @@ |
|||||
// |
|
||||
// module.modulemap |
|
||||
// opus-swift |
|
||||
// |
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
// |
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
// of this software and associated documentation files (the "Software"), to deal |
|
||||
// in the Software without restriction, including without limitation the rights |
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
// copies of the Software, and to permit persons to whom the Software is |
|
||||
// furnished to do so, subject to the following conditions: |
|
||||
// |
|
||||
// The above copyright notice and this permission notice shall be included in all |
|
||||
// copies or substantial portions of the Software. |
|
||||
// |
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||
// SOFTWARE. |
|
||||
// |
|
||||
|
|
||||
framework module YbridOpus { |
|
||||
umbrella header "opus_swift.h" |
|
||||
export * |
|
||||
} |
|
||||
Binary file not shown.
@ -1,207 +0,0 @@ |
|||||
<?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>files</key> |
|
||||
<dict> |
|
||||
<key>Config.xcconfig</key> |
|
||||
<data> |
|
||||
+CifWGfGG+eJ+6RQiR2J6Z9++KM= |
|
||||
</data> |
|
||||
<key>Headers/opus.h</key> |
|
||||
<data> |
|
||||
9iqWh6KOQxloZd6AR4Nln9WTpGM= |
|
||||
</data> |
|
||||
<key>Headers/opus_defines.h</key> |
|
||||
<data> |
|
||||
ZIxZY8da41baCR/GF2/AFpe6cck= |
|
||||
</data> |
|
||||
<key>Headers/opus_multistream.h</key> |
|
||||
<data> |
|
||||
BckYtz94plsXQZ9RBWuV/1kcmxw= |
|
||||
</data> |
|
||||
<key>Headers/opus_swift.h</key> |
|
||||
<data> |
|
||||
LzT5PUj/rbYaW1AxYg5wVXuXbDA= |
|
||||
</data> |
|
||||
<key>Headers/opus_types.h</key> |
|
||||
<data> |
|
||||
4eY+K/HQ77ZaFO9EKPVfVs7L2jM= |
|
||||
</data> |
|
||||
<key>Info.plist</key> |
|
||||
<data> |
|
||||
r3hmihj2/Xt8pdc7857fLj8U+9M= |
|
||||
</data> |
|
||||
<key>Modules/module.modulemap</key> |
|
||||
<data> |
|
||||
fEkglRKWfXEJ5P20WiaR5jn2i6Y= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>files2</key> |
|
||||
<dict> |
|
||||
<key>Config.xcconfig</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
+CifWGfGG+eJ+6RQiR2J6Z9++KM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
yWuzbLu2XVuQ/KyJjefCQA6yUIG/ledJEQXfvayiZ78= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
9iqWh6KOQxloZd6AR4Nln9WTpGM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
jPzA/v85IbzDiXG+tLPzcFiknByl2mtZ+0r2OOIfjuY= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_defines.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
ZIxZY8da41baCR/GF2/AFpe6cck= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
9DvrxB739706a104pEEDAbTM24VK2EL+mF6TUjgCRAs= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_multistream.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
BckYtz94plsXQZ9RBWuV/1kcmxw= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
G/OMOd/e727v31BLWFvk1IgsAeQcWojBJJlSsQpQDvg= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_swift.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
LzT5PUj/rbYaW1AxYg5wVXuXbDA= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
tU2j9To8QDSbhu8Vz/Lv1Y6uYjEGHp0e5a6RsnGglFM= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_types.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
4eY+K/HQ77ZaFO9EKPVfVs7L2jM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
GcswHqHu28vbtQSTY94GGJO/EcIOUFple2nOb/pbEfo= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Modules/module.modulemap</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
fEkglRKWfXEJ5P20WiaR5jn2i6Y= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
spkcimiabUAXiltxFizEevGEO4anKye9lDyB981i/XU= |
|
||||
</data> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
<key>rules</key> |
|
||||
<dict> |
|
||||
<key>^.*</key> |
|
||||
<true/> |
|
||||
<key>^.*\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>optional</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1000</real> |
|
||||
</dict> |
|
||||
<key>^.*\.lproj/locversion.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1100</real> |
|
||||
</dict> |
|
||||
<key>^Base\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>1010</real> |
|
||||
</dict> |
|
||||
<key>^version.plist$</key> |
|
||||
<true/> |
|
||||
</dict> |
|
||||
<key>rules2</key> |
|
||||
<dict> |
|
||||
<key>.*\.dSYM($|/)</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>11</real> |
|
||||
</dict> |
|
||||
<key>^(.*/)?\.DS_Store$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>2000</real> |
|
||||
</dict> |
|
||||
<key>^.*</key> |
|
||||
<true/> |
|
||||
<key>^.*\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>optional</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1000</real> |
|
||||
</dict> |
|
||||
<key>^.*\.lproj/locversion.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1100</real> |
|
||||
</dict> |
|
||||
<key>^Base\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>1010</real> |
|
||||
</dict> |
|
||||
<key>^Info\.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^PkgInfo$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^embedded\.provisionprofile$</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^version\.plist$</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
</plist> |
|
||||
@ -1 +0,0 @@ |
|||||
Versions/Current/Headers |
|
||||
@ -1 +0,0 @@ |
|||||
Versions/Current/Modules |
|
||||
@ -1 +0,0 @@ |
|||||
Versions/Current/Resources |
|
||||
@ -1,981 +0,0 @@ |
|||||
/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
|
|
||||
Written by Jean-Marc Valin and Koen Vos */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus.h |
|
||||
* @brief Opus reference implementation API |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_H |
|
||||
#define OPUS_H |
|
||||
|
|
||||
#include "opus_types.h" |
|
||||
#include "opus_defines.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/**
|
|
||||
* @mainpage Opus |
|
||||
* |
|
||||
* The Opus codec is designed for interactive speech and audio transmission over the Internet. |
|
||||
* It is designed by the IETF Codec Working Group and incorporates technology from |
|
||||
* Skype's SILK codec and Xiph.Org's CELT codec. |
|
||||
* |
|
||||
* The Opus codec is designed to handle a wide range of interactive audio applications, |
|
||||
* including Voice over IP, videoconferencing, in-game chat, and even remote live music |
|
||||
* performances. It can scale from low bit-rate narrowband speech to very high quality |
|
||||
* stereo music. Its main features are: |
|
||||
|
|
||||
* @li Sampling rates from 8 to 48 kHz |
|
||||
* @li Bit-rates from 6 kb/s to 510 kb/s |
|
||||
* @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR) |
|
||||
* @li Audio bandwidth from narrowband to full-band |
|
||||
* @li Support for speech and music |
|
||||
* @li Support for mono and stereo |
|
||||
* @li Support for multichannel (up to 255 channels) |
|
||||
* @li Frame sizes from 2.5 ms to 60 ms |
|
||||
* @li Good loss robustness and packet loss concealment (PLC) |
|
||||
* @li Floating point and fixed-point implementation |
|
||||
* |
|
||||
* Documentation sections: |
|
||||
* @li @ref opus_encoder |
|
||||
* @li @ref opus_decoder |
|
||||
* @li @ref opus_repacketizer |
|
||||
* @li @ref opus_multistream |
|
||||
* @li @ref opus_libinfo |
|
||||
* @li @ref opus_custom |
|
||||
*/ |
|
||||
|
|
||||
/** @defgroup opus_encoder Opus Encoder
|
|
||||
* @{ |
|
||||
* |
|
||||
* @brief This page describes the process and functions used to encode Opus. |
|
||||
* |
|
||||
* Since Opus is a stateful codec, the encoding process starts with creating an encoder |
|
||||
* state. This can be done with: |
|
||||
* |
|
||||
* @code |
|
||||
* int error; |
|
||||
* OpusEncoder *enc; |
|
||||
* enc = opus_encoder_create(Fs, channels, application, &error); |
|
||||
* @endcode |
|
||||
* |
|
||||
* From this point, @c enc can be used for encoding an audio stream. An encoder state |
|
||||
* @b must @b not be used for more than one stream at the same time. Similarly, the encoder |
|
||||
* state @b must @b not be re-initialized for each frame. |
|
||||
* |
|
||||
* While opus_encoder_create() allocates memory for the state, it's also possible |
|
||||
* to initialize pre-allocated memory: |
|
||||
* |
|
||||
* @code |
|
||||
* int size; |
|
||||
* int error; |
|
||||
* OpusEncoder *enc; |
|
||||
* size = opus_encoder_get_size(channels); |
|
||||
* enc = malloc(size); |
|
||||
* error = opus_encoder_init(enc, Fs, channels, application); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where opus_encoder_get_size() returns the required size for the encoder state. Note that |
|
||||
* future versions of this code may change the size, so no assuptions should be made about it. |
|
||||
* |
|
||||
* The encoder state is always continuous in memory and only a shallow copy is sufficient |
|
||||
* to copy it (e.g. memcpy()) |
|
||||
* |
|
||||
* It is possible to change some of the encoder's settings using the opus_encoder_ctl() |
|
||||
* interface. All these settings already default to the recommended value, so they should |
|
||||
* only be changed when necessary. The most common settings one may want to change are: |
|
||||
* |
|
||||
* @code |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate)); |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type)); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where |
|
||||
* |
|
||||
* @arg bitrate is in bits per second (b/s) |
|
||||
* @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest |
|
||||
* @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC |
|
||||
* |
|
||||
* See @ref opus_encoderctls and @ref opus_genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream. |
|
||||
* |
|
||||
* To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data: |
|
||||
* @code |
|
||||
* len = opus_encode(enc, audio_frame, frame_size, packet, max_packet); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where |
|
||||
* <ul> |
|
||||
* <li>audio_frame is the audio data in opus_int16 (or float for opus_encode_float())</li> |
|
||||
* <li>frame_size is the duration of the frame in samples (per channel)</li> |
|
||||
* <li>packet is the byte array to which the compressed data is written</li> |
|
||||
* <li>max_packet is the maximum number of bytes that can be written in the packet (4000 bytes is recommended). |
|
||||
* Do not use max_packet to control VBR target bitrate, instead use the #OPUS_SET_BITRATE CTL.</li> |
|
||||
* </ul> |
|
||||
* |
|
||||
* opus_encode() and opus_encode_float() return the number of bytes actually written to the packet. |
|
||||
* The return value <b>can be negative</b>, which indicates that an error has occurred. If the return value |
|
||||
* is 2 bytes or less, then the packet does not need to be transmitted (DTX). |
|
||||
* |
|
||||
* Once the encoder state if no longer needed, it can be destroyed with |
|
||||
* |
|
||||
* @code |
|
||||
* opus_encoder_destroy(enc); |
|
||||
* @endcode |
|
||||
* |
|
||||
* If the encoder was created with opus_encoder_init() rather than opus_encoder_create(), |
|
||||
* then no action is required aside from potentially freeing the memory that was manually |
|
||||
* allocated for it (calling free(enc) for the example above) |
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
/** Opus encoder state.
|
|
||||
* This contains the complete state of an Opus encoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_encoder_create,opus_encoder_init |
|
||||
*/ |
|
||||
typedef struct OpusEncoder OpusEncoder; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusEncoder</code> structure.
|
|
||||
* @param[in] channels <tt>int</tt>: Number of channels. |
|
||||
* This must be 1 or 2. |
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels); |
|
||||
|
|
||||
/**
|
|
||||
*/ |
|
||||
|
|
||||
/** Allocates and initializes an encoder state.
|
|
||||
* There are three coding modes: |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice |
|
||||
* signals. It enhances the input signal by high-pass filtering and |
|
||||
* emphasizing formants and harmonics. Optionally it includes in-band |
|
||||
* forward error correction to protect against packet loss. Use this |
|
||||
* mode for typical VoIP applications. Because of the enhancement, |
|
||||
* even at high bitrates the output may sound different from the input. |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for most |
|
||||
* non-voice signals like music. Use this mode for music and mixed |
|
||||
* (music/voice) content, broadcast, and applications requiring less |
|
||||
* than 15 ms of coding delay. |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that |
|
||||
* disables the speech-optimized mode in exchange for slightly reduced delay. |
|
||||
* This mode can only be set on an newly initialized or freshly reset encoder |
|
||||
* because it changes the codec delay. |
|
||||
* |
|
||||
* This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution). |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
|
||||
* @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
|
||||
* @param [out] error <tt>int*</tt>: @ref opus_errorcodes |
|
||||
* @note Regardless of the sampling rate and number channels selected, the Opus encoder |
|
||||
* can switch to a lower audio bandwidth or number of channels if the bitrate |
|
||||
* selected is too low. This also means that it is safe to always use 48 kHz stereo input |
|
||||
* and let the encoder optimize the encoding. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int application, |
|
||||
int *error |
|
||||
); |
|
||||
|
|
||||
/** Initializes a previously allocated encoder state
|
|
||||
* The memory pointed to by st must be at least the size returned by opus_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of malloc. |
|
||||
* @see opus_encoder_create(),opus_encoder_get_size() |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
|
||||
* @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
|
||||
* @retval #OPUS_OK Success or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_encoder_init( |
|
||||
OpusEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Encodes an Opus frame.
|
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16) |
|
||||
* @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
|
||||
* input signal. |
|
||||
* This must be an Opus frame size for |
|
||||
* the encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted |
|
||||
* values are 120, 240, 480, 960, 1920, |
|
||||
* and 2880. |
|
||||
* Passing in a duration of less than |
|
||||
* 10 ms (480 samples at 48 kHz) will |
|
||||
* prevent the encoder from using the LPC |
|
||||
* or hybrid modes. |
|
||||
* @param [out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode( |
|
||||
OpusEncoder *st, |
|
||||
const opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Encodes an Opus frame from floating point input.
|
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] pcm <tt>float*</tt>: Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. |
|
||||
* Samples with a range beyond +/-1.0 are supported but will |
|
||||
* be clipped by decoders using the integer API and should |
|
||||
* only be used if it is known that the far end supports |
|
||||
* extended dynamic range. |
|
||||
* length is frame_size*channels*sizeof(float) |
|
||||
* @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
|
||||
* input signal. |
|
||||
* This must be an Opus frame size for |
|
||||
* the encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted |
|
||||
* values are 120, 240, 480, 960, 1920, |
|
||||
* and 2880. |
|
||||
* Passing in a duration of less than |
|
||||
* 10 ms (480 samples at 48 kHz) will |
|
||||
* prevent the encoder from using the LPC |
|
||||
* or hybrid modes. |
|
||||
* @param [out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float( |
|
||||
OpusEncoder *st, |
|
||||
const float *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Frees an <code>OpusEncoder</code> allocated by opus_encoder_create().
|
|
||||
* @param[in] st <tt>OpusEncoder*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st); |
|
||||
|
|
||||
/** Perform a CTL function on an Opus encoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated |
|
||||
* by a convenience macro. |
|
||||
* @param st <tt>OpusEncoder*</tt>: Encoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls or |
|
||||
* @ref opus_encoderctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_encoderctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_decoder Opus Decoder
|
|
||||
* @{ |
|
||||
* |
|
||||
* @brief This page describes the process and functions used to decode Opus. |
|
||||
* |
|
||||
* The decoding process also starts with creating a decoder |
|
||||
* state. This can be done with: |
|
||||
* @code |
|
||||
* int error; |
|
||||
* OpusDecoder *dec; |
|
||||
* dec = opus_decoder_create(Fs, channels, &error); |
|
||||
* @endcode |
|
||||
* where |
|
||||
* @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000 |
|
||||
* @li channels is the number of channels (1 or 2) |
|
||||
* @li error will hold the error code in case of failure (or #OPUS_OK on success) |
|
||||
* @li the return value is a newly created decoder state to be used for decoding |
|
||||
* |
|
||||
* While opus_decoder_create() allocates memory for the state, it's also possible |
|
||||
* to initialize pre-allocated memory: |
|
||||
* @code |
|
||||
* int size; |
|
||||
* int error; |
|
||||
* OpusDecoder *dec; |
|
||||
* size = opus_decoder_get_size(channels); |
|
||||
* dec = malloc(size); |
|
||||
* error = opus_decoder_init(dec, Fs, channels); |
|
||||
* @endcode |
|
||||
* where opus_decoder_get_size() returns the required size for the decoder state. Note that |
|
||||
* future versions of this code may change the size, so no assuptions should be made about it. |
|
||||
* |
|
||||
* The decoder state is always continuous in memory and only a shallow copy is sufficient |
|
||||
* to copy it (e.g. memcpy()) |
|
||||
* |
|
||||
* To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data: |
|
||||
* @code |
|
||||
* frame_size = opus_decode(dec, packet, len, decoded, max_size, 0); |
|
||||
* @endcode |
|
||||
* where |
|
||||
* |
|
||||
* @li packet is the byte array containing the compressed data |
|
||||
* @li len is the exact number of bytes contained in the packet |
|
||||
* @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float()) |
|
||||
* @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array |
|
||||
* |
|
||||
* opus_decode() and opus_decode_float() return the number of samples (per channel) decoded from the packet. |
|
||||
* If that value is negative, then an error has occurred. This can occur if the packet is corrupted or if the audio |
|
||||
* buffer is too small to hold the decoded audio. |
|
||||
* |
|
||||
* Opus is a stateful codec with overlapping blocks and as a result Opus |
|
||||
* packets are not coded independently of each other. Packets must be |
|
||||
* passed into the decoder serially and in the correct order for a correct |
|
||||
* decode. Lost packets can be replaced with loss concealment by calling |
|
||||
* the decoder with a null pointer and zero length for the missing packet. |
|
||||
* |
|
||||
* A single codec state may only be accessed from a single thread at |
|
||||
* a time and any required locking must be performed by the caller. Separate |
|
||||
* streams must be decoded with separate decoder states and can be decoded |
|
||||
* in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK |
|
||||
* defined. |
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
/** Opus decoder state.
|
|
||||
* This contains the complete state of an Opus decoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_decoder_create,opus_decoder_init |
|
||||
*/ |
|
||||
typedef struct OpusDecoder OpusDecoder; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusDecoder</code> structure.
|
|
||||
* @param [in] channels <tt>int</tt>: Number of channels. |
|
||||
* This must be 1 or 2. |
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels); |
|
||||
|
|
||||
/** Allocates and initializes a decoder state.
|
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sample rate to decode at (Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
|
||||
* @param [out] error <tt>int*</tt>: #OPUS_OK Success or @ref opus_errorcodes |
|
||||
* |
|
||||
* Internally Opus stores data at 48000 Hz, so that should be the default |
|
||||
* value for Fs. However, the decoder can efficiently decode to buffers |
|
||||
* at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use |
|
||||
* data at the full sample rate, or knows the compressed data doesn't |
|
||||
* use the full frequency range, it can request decoding at a reduced |
|
||||
* rate. Likewise, the decoder is capable of filling in either mono or |
|
||||
* interleaved stereo pcm buffers, at the caller's request. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int *error |
|
||||
); |
|
||||
|
|
||||
/** Initializes a previously allocated decoder state.
|
|
||||
* The state must be at least the size returned by opus_decoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state. |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate to decode to (Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
|
||||
* @retval #OPUS_OK Success or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_decoder_init( |
|
||||
OpusDecoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels |
|
||||
) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Decode an Opus packet.
|
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
|
||||
* @param [in] len <tt>opus_int32</tt>: Number of bytes in payload* |
|
||||
* @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length |
|
||||
* is frame_size*channels*sizeof(opus_int16) |
|
||||
* @param [in] frame_size Number of samples per channel of available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
|
||||
* not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
|
||||
* then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
|
||||
* FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
|
||||
* decoded. If no such data is available, the frame is decoded as if it were lost. |
|
||||
* @returns Number of decoded samples or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode( |
|
||||
OpusDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Decode an Opus packet with floating point output.
|
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
|
||||
* @param [in] len <tt>opus_int32</tt>: Number of bytes in payload |
|
||||
* @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length |
|
||||
* is frame_size*channels*sizeof(float) |
|
||||
* @param [in] frame_size Number of samples per channel of available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
|
||||
* not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
|
||||
* then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
|
||||
* FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
|
||||
* decoded. If no such data is available the frame is decoded as if it were lost. |
|
||||
* @returns Number of decoded samples or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float( |
|
||||
OpusDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
float *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Perform a CTL function on an Opus decoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated |
|
||||
* by a convenience macro. |
|
||||
* @param st <tt>OpusDecoder*</tt>: Decoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls or |
|
||||
* @ref opus_decoderctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_decoderctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Frees an <code>OpusDecoder</code> allocated by opus_decoder_create().
|
|
||||
* @param[in] st <tt>OpusDecoder*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st); |
|
||||
|
|
||||
/** Parse an opus packet into one or more frames.
|
|
||||
* Opus_decode will perform this operation internally so most applications do |
|
||||
* not need to use this function. |
|
||||
* This function does not copy the frames, the returned pointers are pointers into |
|
||||
* the input packet. |
|
||||
* @param [in] data <tt>char*</tt>: Opus packet to be parsed |
|
||||
* @param [in] len <tt>opus_int32</tt>: size of data |
|
||||
* @param [out] out_toc <tt>char*</tt>: TOC pointer |
|
||||
* @param [out] frames <tt>char*[48]</tt> encapsulated frames |
|
||||
* @param [out] size <tt>opus_int16[48]</tt> sizes of the encapsulated frames |
|
||||
* @param [out] payload_offset <tt>int*</tt>: returns the position of the payload within the packet (in bytes) |
|
||||
* @returns number of frames |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_packet_parse( |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
unsigned char *out_toc, |
|
||||
const unsigned char *frames[48], |
|
||||
opus_int16 size[48], |
|
||||
int *payload_offset |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
/** Gets the bandwidth of an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet |
|
||||
* @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples per frame from an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet. |
|
||||
* This must contain at least one byte of |
|
||||
* data. |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
|
||||
* This must be a multiple of 400, or |
|
||||
* inaccurate results will be returned. |
|
||||
* @returns Number of samples per frame. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of channels from an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet |
|
||||
* @returns Number of channels |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of frames in an Opus packet.
|
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @returns Number of frames |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples of an Opus packet.
|
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
|
||||
* This must be a multiple of 400, or |
|
||||
* inaccurate results will be returned. |
|
||||
* @returns Number of samples |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples of an Opus packet.
|
|
||||
* @param [in] dec <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @returns Number of samples |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
|
||||
|
|
||||
/** Applies soft-clipping to bring a float signal within the [-1,1] range. If
|
|
||||
* the signal is already in that range, nothing is done. If there are values |
|
||||
* outside of [-1,1], then the signal is clipped as smoothly as possible to |
|
||||
* both fit in the range and avoid creating excessive distortion in the |
|
||||
* process. |
|
||||
* @param [in,out] pcm <tt>float*</tt>: Input PCM and modified PCM |
|
||||
* @param [in] frame_size <tt>int</tt> Number of samples per channel to process |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels |
|
||||
* @param [in,out] softclip_mem <tt>float*</tt>: State memory for the soft clipping process (one float per channel, initialized to zero) |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem); |
|
||||
|
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_repacketizer Repacketizer
|
|
||||
* @{ |
|
||||
* |
|
||||
* The repacketizer can be used to merge multiple Opus packets into a single |
|
||||
* packet or alternatively to split Opus packets that have previously been |
|
||||
* merged. Splitting valid Opus packets is always guaranteed to succeed, |
|
||||
* whereas merging valid packets only succeeds if all frames have the same |
|
||||
* mode, bandwidth, and frame size, and when the total duration of the merged |
|
||||
* packet is no more than 120 ms. The 120 ms limit comes from the |
|
||||
* specification and limits decoder memory requirements at a point where |
|
||||
* framing overhead becomes negligible. |
|
||||
* |
|
||||
* The repacketizer currently only operates on elementary Opus |
|
||||
* streams. It will not manipualte multistream packets successfully, except in |
|
||||
* the degenerate case where they consist of data from a single stream. |
|
||||
* |
|
||||
* The repacketizing process starts with creating a repacketizer state, either |
|
||||
* by calling opus_repacketizer_create() or by allocating the memory yourself, |
|
||||
* e.g., |
|
||||
* @code |
|
||||
* OpusRepacketizer *rp; |
|
||||
* rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size()); |
|
||||
* if (rp != NULL) |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* @endcode |
|
||||
* |
|
||||
* Then the application should submit packets with opus_repacketizer_cat(), |
|
||||
* extract new packets with opus_repacketizer_out() or |
|
||||
* opus_repacketizer_out_range(), and then reset the state for the next set of |
|
||||
* input packets via opus_repacketizer_init(). |
|
||||
* |
|
||||
* For example, to split a sequence of packets into individual frames: |
|
||||
* @code |
|
||||
* unsigned char *data; |
|
||||
* int len; |
|
||||
* while (get_next_packet(&data, &len)) |
|
||||
* { |
|
||||
* unsigned char out[1276]; |
|
||||
* opus_int32 out_len; |
|
||||
* int nb_frames; |
|
||||
* int err; |
|
||||
* int i; |
|
||||
* err = opus_repacketizer_cat(rp, data, len); |
|
||||
* if (err != OPUS_OK) |
|
||||
* { |
|
||||
* release_packet(data); |
|
||||
* return err; |
|
||||
* } |
|
||||
* nb_frames = opus_repacketizer_get_nb_frames(rp); |
|
||||
* for (i = 0; i < nb_frames; i++) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out)); |
|
||||
* if (out_len < 0) |
|
||||
* { |
|
||||
* release_packet(data); |
|
||||
* return (int)out_len; |
|
||||
* } |
|
||||
* output_next_packet(out, out_len); |
|
||||
* } |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* release_packet(data); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* Alternatively, to combine a sequence of frames into packets that each |
|
||||
* contain up to <code>TARGET_DURATION_MS</code> milliseconds of data: |
|
||||
* @code |
|
||||
* // The maximum number of packets with duration TARGET_DURATION_MS occurs
|
|
||||
* // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5)
|
|
||||
* // packets.
|
|
||||
* unsigned char *data[(TARGET_DURATION_MS*2/5)+1]; |
|
||||
* opus_int32 len[(TARGET_DURATION_MS*2/5)+1]; |
|
||||
* int nb_packets; |
|
||||
* unsigned char out[1277*(TARGET_DURATION_MS*2/2)]; |
|
||||
* opus_int32 out_len; |
|
||||
* int prev_toc; |
|
||||
* nb_packets = 0; |
|
||||
* while (get_next_packet(data+nb_packets, len+nb_packets)) |
|
||||
* { |
|
||||
* int nb_frames; |
|
||||
* int err; |
|
||||
* nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]); |
|
||||
* if (nb_frames < 1) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return nb_frames; |
|
||||
* } |
|
||||
* nb_frames += opus_repacketizer_get_nb_frames(rp); |
|
||||
* // If adding the next packet would exceed our target, or it has an
|
|
||||
* // incompatible TOC sequence, output the packets we already have before
|
|
||||
* // submitting it.
|
|
||||
* // N.B., The nb_packets > 0 check ensures we've submitted at least one
|
|
||||
* // packet since the last call to opus_repacketizer_init(). Otherwise a
|
|
||||
* // single packet longer than TARGET_DURATION_MS would cause us to try to
|
|
||||
* // output an (invalid) empty packet. It also ensures that prev_toc has
|
|
||||
* // been set to a valid value. Additionally, len[nb_packets] > 0 is
|
|
||||
* // guaranteed by the call to opus_packet_get_nb_frames() above, so the
|
|
||||
* // reference to data[nb_packets][0] should be valid.
|
|
||||
* if (nb_packets > 0 && ( |
|
||||
* ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) || |
|
||||
* opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames > |
|
||||
* TARGET_DURATION_MS*48)) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
|
||||
* if (out_len < 0) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return (int)out_len; |
|
||||
* } |
|
||||
* output_next_packet(out, out_len); |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* release_packets(data, nb_packets); |
|
||||
* data[0] = data[nb_packets]; |
|
||||
* len[0] = len[nb_packets]; |
|
||||
* nb_packets = 0; |
|
||||
* } |
|
||||
* err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]); |
|
||||
* if (err != OPUS_OK) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return err; |
|
||||
* } |
|
||||
* prev_toc = data[nb_packets][0]; |
|
||||
* nb_packets++; |
|
||||
* } |
|
||||
* // Output the final, partial packet.
|
|
||||
* if (nb_packets > 0) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
|
||||
* release_packets(data, nb_packets); |
|
||||
* if (out_len < 0) |
|
||||
* return (int)out_len; |
|
||||
* output_next_packet(out, out_len); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* An alternate way of merging packets is to simply call opus_repacketizer_cat() |
|
||||
* unconditionally until it fails. At that point, the merged packet can be |
|
||||
* obtained with opus_repacketizer_out() and the input packet for which |
|
||||
* opus_repacketizer_cat() needs to be re-added to a newly reinitialized |
|
||||
* repacketizer state. |
|
||||
*/ |
|
||||
|
|
||||
typedef struct OpusRepacketizer OpusRepacketizer; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusRepacketizer</code> structure.
|
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void); |
|
||||
|
|
||||
/** (Re)initializes a previously allocated repacketizer state.
|
|
||||
* The state must be at least the size returned by opus_repacketizer_get_size(). |
|
||||
* This can be used for applications which use their own allocator instead of |
|
||||
* malloc(). |
|
||||
* It must also be called to reset the queue of packets waiting to be |
|
||||
* repacketized, which is necessary if the maximum packet duration of 120 ms |
|
||||
* is reached or if you wish to submit packets with a different Opus |
|
||||
* configuration (coding mode, audio bandwidth, frame size, or channel count). |
|
||||
* Failure to do so will prevent a new packet from being added with |
|
||||
* opus_repacketizer_cat(). |
|
||||
* @see opus_repacketizer_create |
|
||||
* @see opus_repacketizer_get_size |
|
||||
* @see opus_repacketizer_cat |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to |
|
||||
* (re)initialize. |
|
||||
* @returns A pointer to the same repacketizer state that was passed in. |
|
||||
*/ |
|
||||
OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Allocates memory and initializes the new repacketizer with
|
|
||||
* opus_repacketizer_init(). |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void); |
|
||||
|
|
||||
/** Frees an <code>OpusRepacketizer</code> allocated by
|
|
||||
* opus_repacketizer_create(). |
|
||||
* @param[in] rp <tt>OpusRepacketizer*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp); |
|
||||
|
|
||||
/** Add a packet to the current repacketizer state.
|
|
||||
* This packet must match the configuration of any packets already submitted |
|
||||
* for repacketization since the last call to opus_repacketizer_init(). |
|
||||
* This means that it must have the same coding mode, audio bandwidth, frame |
|
||||
* size, and channel count. |
|
||||
* This can be checked in advance by examining the top 6 bits of the first |
|
||||
* byte of the packet, and ensuring they match the top 6 bits of the first |
|
||||
* byte of any previously submitted packet. |
|
||||
* The total duration of audio in the repacketizer state also must not exceed |
|
||||
* 120 ms, the maximum duration of a single packet, after adding this packet. |
|
||||
* |
|
||||
* The contents of the current repacketizer state can be extracted into new |
|
||||
* packets using opus_repacketizer_out() or opus_repacketizer_out_range(). |
|
||||
* |
|
||||
* In order to add a packet with a different configuration or to add more |
|
||||
* audio beyond 120 ms, you must clear the repacketizer state by calling |
|
||||
* opus_repacketizer_init(). |
|
||||
* If a packet is too large to add to the current repacketizer state, no part |
|
||||
* of it is added, even if it contains multiple frames, some of which might |
|
||||
* fit. |
|
||||
* If you wish to be able to add parts of such packets, you should first use |
|
||||
* another repacketizer to split the packet into pieces and add them |
|
||||
* individually. |
|
||||
* @see opus_repacketizer_out_range |
|
||||
* @see opus_repacketizer_out |
|
||||
* @see opus_repacketizer_init |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to which to |
|
||||
* add the packet. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: The packet data. |
|
||||
* The application must ensure |
|
||||
* this pointer remains valid |
|
||||
* until the next call to |
|
||||
* opus_repacketizer_init() or |
|
||||
* opus_repacketizer_destroy(). |
|
||||
* @param len <tt>opus_int32</tt>: The number of bytes in the packet data. |
|
||||
* @returns An error code indicating whether or not the operation succeeded. |
|
||||
* @retval #OPUS_OK The packet's contents have been added to the repacketizer |
|
||||
* state. |
|
||||
* @retval #OPUS_INVALID_PACKET The packet did not have a valid TOC sequence, |
|
||||
* the packet's TOC sequence was not compatible |
|
||||
* with previously submitted packets (because |
|
||||
* the coding mode, audio bandwidth, frame size, |
|
||||
* or channel count did not match), or adding |
|
||||
* this packet would increase the total amount of |
|
||||
* audio stored in the repacketizer state to more |
|
||||
* than 120 ms. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
|
||||
|
|
||||
|
|
||||
/** Construct a new packet from data previously submitted to the repacketizer
|
|
||||
* state via opus_repacketizer_cat(). |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
|
||||
* construct the new packet. |
|
||||
* @param begin <tt>int</tt>: The index of the first frame in the current |
|
||||
* repacketizer state to include in the output. |
|
||||
* @param end <tt>int</tt>: One past the index of the last frame in the |
|
||||
* current repacketizer state to include in the |
|
||||
* output. |
|
||||
* @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
|
||||
* store the output packet. |
|
||||
* @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
|
||||
* the output buffer. In order to guarantee |
|
||||
* success, this should be at least |
|
||||
* <code>1276</code> for a single frame, |
|
||||
* or for multiple frames, |
|
||||
* <code>1277*(end-begin)</code>. |
|
||||
* However, <code>1*(end-begin)</code> plus |
|
||||
* the size of all packet data submitted to |
|
||||
* the repacketizer since the last call to |
|
||||
* opus_repacketizer_init() or |
|
||||
* opus_repacketizer_create() is also |
|
||||
* sufficient, and possibly much smaller. |
|
||||
* @returns The total size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG <code>[begin,end)</code> was an invalid range of |
|
||||
* frames (begin < 0, begin >= end, or end > |
|
||||
* opus_repacketizer_get_nb_frames()). |
|
||||
* @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
|
||||
* complete output packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Return the total number of frames contained in packet data submitted to
|
|
||||
* the repacketizer state so far via opus_repacketizer_cat() since the last |
|
||||
* call to opus_repacketizer_init() or opus_repacketizer_create(). |
|
||||
* This defines the valid range of packets that can be extracted with |
|
||||
* opus_repacketizer_out_range() or opus_repacketizer_out(). |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state containing the |
|
||||
* frames. |
|
||||
* @returns The total number of frames contained in the packet data submitted |
|
||||
* to the repacketizer state. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Construct a new packet from data previously submitted to the repacketizer
|
|
||||
* state via opus_repacketizer_cat(). |
|
||||
* This is a convenience routine that returns all the data submitted so far |
|
||||
* in a single packet. |
|
||||
* It is equivalent to calling |
|
||||
* @code |
|
||||
* opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp), |
|
||||
* data, maxlen) |
|
||||
* @endcode |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
|
||||
* construct the new packet. |
|
||||
* @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
|
||||
* store the output packet. |
|
||||
* @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
|
||||
* the output buffer. In order to guarantee |
|
||||
* success, this should be at least |
|
||||
* <code>1277*opus_repacketizer_get_nb_frames(rp)</code>. |
|
||||
* However, |
|
||||
* <code>1*opus_repacketizer_get_nb_frames(rp)</code> |
|
||||
* plus the size of all packet data |
|
||||
* submitted to the repacketizer since the |
|
||||
* last call to opus_repacketizer_init() or |
|
||||
* opus_repacketizer_create() is also |
|
||||
* sufficient, and possibly much smaller. |
|
||||
* @returns The total size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
|
||||
* complete output packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Pads a given Opus packet to a larger size (possibly changing the TOC sequence).
|
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to pad. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
|
||||
* This must be at least as large as len. |
|
||||
* @returns an error code |
|
||||
* @retval #OPUS_OK \a on success. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len); |
|
||||
|
|
||||
/** Remove all padding from a given Opus packet and rewrite the TOC sequence to
|
|
||||
* minimize space usage. |
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to strip. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @returns The new size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len); |
|
||||
|
|
||||
/** Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence).
|
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to pad. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
|
||||
* This must be at least 1. |
|
||||
* @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
|
||||
* This must be at least as large as len. |
|
||||
* @returns an error code |
|
||||
* @retval #OPUS_OK \a on success. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams); |
|
||||
|
|
||||
/** Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to
|
|
||||
* minimize space usage. |
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to strip. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
|
||||
* This must be at least 1. |
|
||||
* @returns The new size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_H */ |
|
||||
@ -1,799 +0,0 @@ |
|||||
/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
|
|
||||
Written by Jean-Marc Valin and Koen Vos */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus_defines.h |
|
||||
* @brief Opus reference implementation constants |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_DEFINES_H |
|
||||
#define OPUS_DEFINES_H |
|
||||
|
|
||||
#include "opus_types.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/** @defgroup opus_errorcodes Error codes
|
|
||||
* @{ |
|
||||
*/ |
|
||||
/** No error @hideinitializer*/ |
|
||||
#define OPUS_OK 0 |
|
||||
/** One or more invalid/out of range arguments @hideinitializer*/ |
|
||||
#define OPUS_BAD_ARG -1 |
|
||||
/** Not enough bytes allocated in the buffer @hideinitializer*/ |
|
||||
#define OPUS_BUFFER_TOO_SMALL -2 |
|
||||
/** An internal error was detected @hideinitializer*/ |
|
||||
#define OPUS_INTERNAL_ERROR -3 |
|
||||
/** The compressed data passed is corrupted @hideinitializer*/ |
|
||||
#define OPUS_INVALID_PACKET -4 |
|
||||
/** Invalid/unsupported request number @hideinitializer*/ |
|
||||
#define OPUS_UNIMPLEMENTED -5 |
|
||||
/** An encoder or decoder structure is invalid or already freed @hideinitializer*/ |
|
||||
#define OPUS_INVALID_STATE -6 |
|
||||
/** Memory allocation has failed @hideinitializer*/ |
|
||||
#define OPUS_ALLOC_FAIL -7 |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @cond OPUS_INTERNAL_DOC */ |
|
||||
/**Export control for opus functions */ |
|
||||
|
|
||||
#ifndef OPUS_EXPORT |
|
||||
# if defined(WIN32) |
|
||||
# if defined(OPUS_BUILD) && defined(DLL_EXPORT) |
|
||||
# define OPUS_EXPORT __declspec(dllexport) |
|
||||
# else |
|
||||
# define OPUS_EXPORT |
|
||||
# endif |
|
||||
# elif defined(__GNUC__) && defined(OPUS_BUILD) |
|
||||
# define OPUS_EXPORT __attribute__ ((visibility ("default"))) |
|
||||
# else |
|
||||
# define OPUS_EXPORT |
|
||||
# endif |
|
||||
#endif |
|
||||
|
|
||||
# if !defined(OPUS_GNUC_PREREQ) |
|
||||
# if defined(__GNUC__)&&defined(__GNUC_MINOR__) |
|
||||
# define OPUS_GNUC_PREREQ(_maj,_min) \ |
|
||||
((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) |
|
||||
# else |
|
||||
# define OPUS_GNUC_PREREQ(_maj,_min) 0 |
|
||||
# endif |
|
||||
# endif |
|
||||
|
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
|
||||
# if OPUS_GNUC_PREREQ(3,0) |
|
||||
# define OPUS_RESTRICT __restrict__ |
|
||||
# elif (defined(_MSC_VER) && _MSC_VER >= 1400) |
|
||||
# define OPUS_RESTRICT __restrict |
|
||||
# else |
|
||||
# define OPUS_RESTRICT |
|
||||
# endif |
|
||||
#else |
|
||||
# define OPUS_RESTRICT restrict |
|
||||
#endif |
|
||||
|
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
|
||||
# if OPUS_GNUC_PREREQ(2,7) |
|
||||
# define OPUS_INLINE __inline__ |
|
||||
# elif (defined(_MSC_VER)) |
|
||||
# define OPUS_INLINE __inline |
|
||||
# else |
|
||||
# define OPUS_INLINE |
|
||||
# endif |
|
||||
#else |
|
||||
# define OPUS_INLINE inline |
|
||||
#endif |
|
||||
|
|
||||
/**Warning attributes for opus functions
|
|
||||
* NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out |
|
||||
* some paranoid null checks. */ |
|
||||
#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
|
||||
# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) |
|
||||
#else |
|
||||
# define OPUS_WARN_UNUSED_RESULT |
|
||||
#endif |
|
||||
#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
|
||||
# define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) |
|
||||
#else |
|
||||
# define OPUS_ARG_NONNULL(_x) |
|
||||
#endif |
|
||||
|
|
||||
/** These are the actual Encoder CTL ID numbers.
|
|
||||
* They should not be used directly by applications. |
|
||||
* In general, SETs should be even and GETs should be odd.*/ |
|
||||
#define OPUS_SET_APPLICATION_REQUEST 4000 |
|
||||
#define OPUS_GET_APPLICATION_REQUEST 4001 |
|
||||
#define OPUS_SET_BITRATE_REQUEST 4002 |
|
||||
#define OPUS_GET_BITRATE_REQUEST 4003 |
|
||||
#define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 |
|
||||
#define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 |
|
||||
#define OPUS_SET_VBR_REQUEST 4006 |
|
||||
#define OPUS_GET_VBR_REQUEST 4007 |
|
||||
#define OPUS_SET_BANDWIDTH_REQUEST 4008 |
|
||||
#define OPUS_GET_BANDWIDTH_REQUEST 4009 |
|
||||
#define OPUS_SET_COMPLEXITY_REQUEST 4010 |
|
||||
#define OPUS_GET_COMPLEXITY_REQUEST 4011 |
|
||||
#define OPUS_SET_INBAND_FEC_REQUEST 4012 |
|
||||
#define OPUS_GET_INBAND_FEC_REQUEST 4013 |
|
||||
#define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 |
|
||||
#define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 |
|
||||
#define OPUS_SET_DTX_REQUEST 4016 |
|
||||
#define OPUS_GET_DTX_REQUEST 4017 |
|
||||
#define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 |
|
||||
#define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 |
|
||||
#define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 |
|
||||
#define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 |
|
||||
#define OPUS_SET_SIGNAL_REQUEST 4024 |
|
||||
#define OPUS_GET_SIGNAL_REQUEST 4025 |
|
||||
#define OPUS_GET_LOOKAHEAD_REQUEST 4027 |
|
||||
/* #define OPUS_RESET_STATE 4028 */ |
|
||||
#define OPUS_GET_SAMPLE_RATE_REQUEST 4029 |
|
||||
#define OPUS_GET_FINAL_RANGE_REQUEST 4031 |
|
||||
#define OPUS_GET_PITCH_REQUEST 4033 |
|
||||
#define OPUS_SET_GAIN_REQUEST 4034 |
|
||||
#define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */ |
|
||||
#define OPUS_SET_LSB_DEPTH_REQUEST 4036 |
|
||||
#define OPUS_GET_LSB_DEPTH_REQUEST 4037 |
|
||||
#define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039 |
|
||||
#define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040 |
|
||||
#define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041 |
|
||||
#define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042 |
|
||||
#define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043 |
|
||||
/* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */ |
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046 |
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047 |
|
||||
#define OPUS_GET_IN_DTX_REQUEST 4049 |
|
||||
|
|
||||
/** Defines for the presence of extended APIs. */ |
|
||||
#define OPUS_HAVE_OPUS_PROJECTION_H |
|
||||
|
|
||||
/* Macros to trigger compilation errors when the wrong types are provided to a CTL */ |
|
||||
#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) |
|
||||
#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) |
|
||||
#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) |
|
||||
#define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr))) |
|
||||
/** @endcond */ |
|
||||
|
|
||||
/** @defgroup opus_ctlvalues Pre-defined values for CTL interface
|
|
||||
* @see opus_genericctls, opus_encoderctls |
|
||||
* @{ |
|
||||
*/ |
|
||||
/* Values for the various encoder CTLs */ |
|
||||
#define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/ |
|
||||
#define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/ |
|
||||
|
|
||||
/** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_VOIP 2048 |
|
||||
/** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_AUDIO 2049 |
|
||||
/** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 |
|
||||
|
|
||||
#define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */ |
|
||||
#define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */ |
|
||||
#define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hideinitializer*/ |
|
||||
|
|
||||
#define OPUS_FRAMESIZE_ARG 5000 /**< Select frame size from the argument (default) */ |
|
||||
#define OPUS_FRAMESIZE_2_5_MS 5001 /**< Use 2.5 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_5_MS 5002 /**< Use 5 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_10_MS 5003 /**< Use 10 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_20_MS 5004 /**< Use 20 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_40_MS 5005 /**< Use 40 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_60_MS 5006 /**< Use 60 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_80_MS 5007 /**< Use 80 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_100_MS 5008 /**< Use 100 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_120_MS 5009 /**< Use 120 ms frames */ |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
|
|
||||
/** @defgroup opus_encoderctls Encoder related CTLs
|
|
||||
* |
|
||||
* These are convenience macros for use with the \c opus_encode_ctl |
|
||||
* interface. They are used to generate the appropriate series of |
|
||||
* arguments for that call, passing the correct type, size and so |
|
||||
* on as expected for each particular request. |
|
||||
* |
|
||||
* Some usage examples: |
|
||||
* |
|
||||
* @code |
|
||||
* int ret; |
|
||||
* ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); |
|
||||
* if (ret != OPUS_OK) return ret; |
|
||||
* |
|
||||
* opus_int32 rate; |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); |
|
||||
* |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
|
||||
* @endcode |
|
||||
* |
|
||||
* @see opus_genericctls, opus_encoder |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Configures the encoder's computational complexity.
|
|
||||
* The supported range is 0-10 inclusive with 10 representing the highest complexity. |
|
||||
* @see OPUS_GET_COMPLEXITY |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive. |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's complexity configuration.
|
|
||||
* @see OPUS_SET_COMPLEXITY |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10, |
|
||||
* inclusive. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the bitrate in the encoder.
|
|
||||
* Rates from 500 to 512000 bits per second are meaningful, as well as the |
|
||||
* special values #OPUS_AUTO and #OPUS_BITRATE_MAX. |
|
||||
* The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much |
|
||||
* rate as it can, which is useful for controlling the rate by adjusting the |
|
||||
* output buffer size. |
|
||||
* @see OPUS_GET_BITRATE |
|
||||
* @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default |
|
||||
* is determined based on the number of |
|
||||
* channels and the input sampling rate. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's bitrate configuration.
|
|
||||
* @see OPUS_SET_BITRATE |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second. |
|
||||
* The default is determined based on the |
|
||||
* number of channels and the input |
|
||||
* sampling rate. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Enables or disables variable bitrate (VBR) in the encoder.
|
|
||||
* The configured bitrate may not be met exactly because frames must |
|
||||
* be an integer number of bytes in length. |
|
||||
* @see OPUS_GET_VBR |
|
||||
* @see OPUS_SET_VBR_CONSTRAINT |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can |
|
||||
* cause noticeable quality degradation.</dd> |
|
||||
* <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by |
|
||||
* #OPUS_SET_VBR_CONSTRAINT.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) |
|
||||
/** Determine if variable bitrate (VBR) is enabled in the encoder.
|
|
||||
* @see OPUS_SET_VBR |
|
||||
* @see OPUS_GET_VBR_CONSTRAINT |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Hard CBR.</dd> |
|
||||
* <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via |
|
||||
* #OPUS_GET_VBR_CONSTRAINT.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Enables or disables constrained VBR in the encoder.
|
|
||||
* This setting is ignored when the encoder is in CBR mode. |
|
||||
* @warning Only the MDCT mode of Opus currently heeds the constraint. |
|
||||
* Speech mode ignores it completely, hybrid mode may fail to obey it |
|
||||
* if the LPC layer uses more bitrate than the constraint would have |
|
||||
* permitted. |
|
||||
* @see OPUS_GET_VBR_CONSTRAINT |
|
||||
* @see OPUS_SET_VBR |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Unconstrained VBR.</dd> |
|
||||
* <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one |
|
||||
* frame of buffering delay assuming a transport with a |
|
||||
* serialization speed of the nominal bitrate.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x) |
|
||||
/** Determine if constrained VBR is enabled in the encoder.
|
|
||||
* @see OPUS_SET_VBR_CONSTRAINT |
|
||||
* @see OPUS_GET_VBR |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Unconstrained VBR.</dd> |
|
||||
* <dt>1</dt><dd>Constrained VBR (default).</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures mono/stereo forcing in the encoder.
|
|
||||
* This can force the encoder to produce packets encoded as either mono or |
|
||||
* stereo, regardless of the format of the input audio. This is useful when |
|
||||
* the caller knows that the input signal is currently a mono source embedded |
|
||||
* in a stereo stream. |
|
||||
* @see OPUS_GET_FORCE_CHANNELS |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
|
||||
* <dt>1</dt> <dd>Forced mono</dd> |
|
||||
* <dt>2</dt> <dd>Forced stereo</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's forced channel configuration.
|
|
||||
* @see OPUS_SET_FORCE_CHANNELS |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
|
||||
* <dt>1</dt> <dd>Forced mono</dd> |
|
||||
* <dt>2</dt> <dd>Forced stereo</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the maximum bandpass that the encoder will select automatically.
|
|
||||
* Applications should normally use this instead of #OPUS_SET_BANDWIDTH |
|
||||
* (leaving that set to the default, #OPUS_AUTO). This allows the |
|
||||
* application to set an upper bound based on the type of input it is |
|
||||
* providing, but still gives the encoder the freedom to reduce the bandpass |
|
||||
* when the bitrate becomes too low, for better overall quality. |
|
||||
* @see OPUS_GET_MAX_BANDWIDTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x) |
|
||||
|
|
||||
/** Gets the encoder's configured maximum allowed bandpass.
|
|
||||
* @see OPUS_SET_MAX_BANDWIDTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Sets the encoder's bandpass to a specific value.
|
|
||||
* This prevents the encoder from automatically selecting the bandpass based |
|
||||
* on the available bitrate. If an application knows the bandpass of the input |
|
||||
* audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH |
|
||||
* instead, which still gives the encoder the freedom to reduce the bandpass |
|
||||
* when the bitrate becomes too low, for better overall quality. |
|
||||
* @see OPUS_GET_BANDWIDTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) |
|
||||
|
|
||||
/** Configures the type of signal being encoded.
|
|
||||
* This is a hint which helps the encoder's mode selection. |
|
||||
* @see OPUS_GET_SIGNAL |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
|
||||
* <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured signal type.
|
|
||||
* @see OPUS_SET_SIGNAL |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
|
||||
* <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
|
|
||||
/** Configures the encoder's intended application.
|
|
||||
* The initial value is a mandatory argument to the encoder_create function. |
|
||||
* @see OPUS_GET_APPLICATION |
|
||||
* @param[in] x <tt>opus_int32</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured application.
|
|
||||
* @see OPUS_SET_APPLICATION |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the total samples of delay added by the entire codec.
|
|
||||
* This can be queried by the encoder and then the provided number of samples can be |
|
||||
* skipped on from the start of the decoder's output to provide time aligned input |
|
||||
* and output. From the perspective of a decoding application the real data begins this many |
|
||||
* samples late. |
|
||||
* |
|
||||
* The decoder contribution to this delay is identical for all decoders, but the |
|
||||
* encoder portion of the delay may vary from implementation to implementation, |
|
||||
* version to version, or even depend on the encoder's initial configuration. |
|
||||
* Applications needing delay compensation should call this CTL rather than |
|
||||
* hard-coding a value. |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of inband forward error correction (FEC).
|
|
||||
* @note This is only applicable to the LPC layer |
|
||||
* @see OPUS_GET_INBAND_FEC |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Disable inband FEC (default).</dd> |
|
||||
* <dt>1</dt><dd>Enable inband FEC.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) |
|
||||
/** Gets encoder's configured use of inband forward error correction.
|
|
||||
* @see OPUS_SET_INBAND_FEC |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Inband FEC disabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Inband FEC enabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's expected packet loss percentage.
|
|
||||
* Higher values trigger progressively more loss resistant behavior in the encoder |
|
||||
* at the expense of quality at a given bitrate in the absence of packet loss, but |
|
||||
* greater quality under loss. |
|
||||
* @see OPUS_GET_PACKET_LOSS_PERC |
|
||||
* @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured packet loss percentage.
|
|
||||
* @see OPUS_SET_PACKET_LOSS_PERC |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage |
|
||||
* in the range 0-100, inclusive (default: 0). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of discontinuous transmission (DTX).
|
|
||||
* @note This is only applicable to the LPC layer |
|
||||
* @see OPUS_GET_DTX |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Disable DTX (default).</dd> |
|
||||
* <dt>1</dt><dd>Enabled DTX.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) |
|
||||
/** Gets encoder's configured use of discontinuous transmission.
|
|
||||
* @see OPUS_SET_DTX |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>DTX disabled (default).</dd> |
|
||||
* <dt>1</dt><dd>DTX enabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) |
|
||||
/** Configures the depth of signal being encoded.
|
|
||||
* |
|
||||
* This is a hint which helps the encoder identify silence and near-silence. |
|
||||
* It represents the number of significant bits of linear intensity below |
|
||||
* which the signal contains ignorable quantization or other noise. |
|
||||
* |
|
||||
* For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting |
|
||||
* for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate |
|
||||
* for 16-bit linear pcm input with opus_encode_float(). |
|
||||
* |
|
||||
* When using opus_encode() instead of opus_encode_float(), or when libopus |
|
||||
* is compiled for fixed-point, the encoder uses the minimum of the value |
|
||||
* set here and the value 16. |
|
||||
* |
|
||||
* @see OPUS_GET_LSB_DEPTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24 |
|
||||
* (default: 24). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured signal depth.
|
|
||||
* @see OPUS_SET_LSB_DEPTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and |
|
||||
* 24 (default: 24). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of variable duration frames.
|
|
||||
* When variable duration is enabled, the encoder is free to use a shorter frame |
|
||||
* size than the one requested in the opus_encode*() call. |
|
||||
* It is then the user's responsibility |
|
||||
* to verify how much audio was encoded by checking the ToC byte of the encoded |
|
||||
* packet. The part of the audio that was not encoded needs to be resent to the |
|
||||
* encoder for the next call. Do not use this option unless you <b>really</b> |
|
||||
* know what you are doing. |
|
||||
* @see OPUS_GET_EXPERT_FRAME_DURATION |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured use of variable duration frames.
|
|
||||
* @see OPUS_SET_EXPERT_FRAME_DURATION |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** If set to 1, disables almost all use of prediction, making frames almost
|
|
||||
* completely independent. This reduces quality. |
|
||||
* @see OPUS_GET_PREDICTION_DISABLED |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Enable prediction (default).</dd> |
|
||||
* <dt>1</dt><dd>Disable prediction.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured prediction status.
|
|
||||
* @see OPUS_SET_PREDICTION_DISABLED |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Prediction enabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Prediction disabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_genericctls Generic CTLs
|
|
||||
* |
|
||||
* These macros are used with the \c opus_decoder_ctl and |
|
||||
* \c opus_encoder_ctl calls to generate a particular |
|
||||
* request. |
|
||||
* |
|
||||
* When called on an \c OpusDecoder they apply to that |
|
||||
* particular decoder instance. When called on an |
|
||||
* \c OpusEncoder they apply to the corresponding setting |
|
||||
* on that encoder instance, if present. |
|
||||
* |
|
||||
* Some usage examples: |
|
||||
* |
|
||||
* @code |
|
||||
* int ret; |
|
||||
* opus_int32 pitch; |
|
||||
* ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); |
|
||||
* if (ret == OPUS_OK) return ret; |
|
||||
* |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
|
||||
* opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); |
|
||||
* |
|
||||
* opus_int32 enc_bw, dec_bw; |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); |
|
||||
* opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); |
|
||||
* if (enc_bw != dec_bw) { |
|
||||
* printf("packet bandwidth mismatch!\n"); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Resets the codec state to be equivalent to a freshly initialized state.
|
|
||||
* This should be called when switching streams in order to prevent |
|
||||
* the back to back decoding from giving different results from |
|
||||
* one at a time decoding. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_RESET_STATE 4028 |
|
||||
|
|
||||
/** Gets the final state of the codec's entropy coder.
|
|
||||
* This is used for testing purposes, |
|
||||
* The encoder and decoder state should be identical after coding a payload |
|
||||
* (assuming no data corruption or software bugs) |
|
||||
* |
|
||||
* @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) |
|
||||
|
|
||||
/** Gets the encoder's configured bandpass or the decoder's last bandpass.
|
|
||||
* @see OPUS_SET_BANDWIDTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the sampling rate the encoder or decoder was initialized with.
|
|
||||
* This simply returns the <code>Fs</code> value passed to opus_encoder_init() |
|
||||
* or opus_decoder_init(). |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** If set to 1, disables the use of phase inversion for intensity stereo,
|
|
||||
* improving the quality of mono downmixes, but slightly reducing normal |
|
||||
* stereo quality. Disabling phase inversion in the decoder does not comply |
|
||||
* with RFC 6716, although it does not cause any interoperability issue and |
|
||||
* is expected to become part of the Opus standard once RFC 6716 is updated |
|
||||
* by draft-ietf-codec-opus-update. |
|
||||
* @see OPUS_GET_PHASE_INVERSION_DISABLED |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Enable phase inversion (default).</dd> |
|
||||
* <dt>1</dt><dd>Disable phase inversion.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured phase inversion status.
|
|
||||
* @see OPUS_SET_PHASE_INVERSION_DISABLED |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Stereo phase inversion enabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Stereo phase inversion disabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
|
||||
/** Gets the DTX state of the encoder.
|
|
||||
* Returns whether the last encoded frame was either a comfort noise update |
|
||||
* during DTX or not encoded because of DTX. |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>The encoder is not in DTX.</dd> |
|
||||
* <dt>1</dt><dd>The encoder is in DTX.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_IN_DTX(x) OPUS_GET_IN_DTX_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_decoderctls Decoder related CTLs
|
|
||||
* @see opus_genericctls, opus_encoderctls, opus_decoder |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Configures decoder gain adjustment.
|
|
||||
* Scales the decoded output by a factor specified in Q8 dB units. |
|
||||
* This has a maximum range of -32768 to 32767 inclusive, and returns |
|
||||
* OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. |
|
||||
* This setting survives decoder reset. |
|
||||
* |
|
||||
* gain = pow(10, x/(20.0*256)) |
|
||||
* |
|
||||
* @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN
|
|
||||
* |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the duration (in samples) of the last packet successfully decoded or concealed.
|
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the pitch of the last decoded frame, if available.
|
|
||||
* This can be used for any post-processing algorithm requiring the use of pitch, |
|
||||
* e.g. time stretching/shortening. If the last frame was not voiced, or if the |
|
||||
* pitch was not coded in the frame, then zero is returned. |
|
||||
* |
|
||||
* This CTL is only implemented for decoder instances. |
|
||||
* |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available) |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_libinfo Opus library information functions
|
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Converts an opus error code into a human readable string.
|
|
||||
* |
|
||||
* @param[in] error <tt>int</tt>: Error number |
|
||||
* @returns Error string |
|
||||
*/ |
|
||||
OPUS_EXPORT const char *opus_strerror(int error); |
|
||||
|
|
||||
/** Gets the libopus version string.
|
|
||||
* |
|
||||
* Applications may look for the substring "-fixed" in the version string to |
|
||||
* determine whether they have a fixed-point or floating-point build at |
|
||||
* runtime. |
|
||||
* |
|
||||
* @returns Version string |
|
||||
*/ |
|
||||
OPUS_EXPORT const char *opus_get_version_string(void); |
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_DEFINES_H */ |
|
||||
@ -1,660 +0,0 @@ |
|||||
/* Copyright (c) 2011 Xiph.Org Foundation
|
|
||||
Written by Jean-Marc Valin */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus_multistream.h |
|
||||
* @brief Opus reference implementation multistream API |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_MULTISTREAM_H |
|
||||
#define OPUS_MULTISTREAM_H |
|
||||
|
|
||||
#include "opus.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/** @cond OPUS_INTERNAL_DOC */ |
|
||||
|
|
||||
/** Macros to trigger compilation errors when the wrong types are provided to a
|
|
||||
* CTL. */ |
|
||||
/**@{*/ |
|
||||
#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr))) |
|
||||
#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr))) |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** These are the actual encoder and decoder CTL ID numbers.
|
|
||||
* They should not be used directly by applications. |
|
||||
* In general, SETs should be even and GETs should be odd.*/ |
|
||||
/**@{*/ |
|
||||
#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120 |
|
||||
#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122 |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @endcond */ |
|
||||
|
|
||||
/** @defgroup opus_multistream_ctls Multistream specific encoder and decoder CTLs
|
|
||||
* |
|
||||
* These are convenience macros that are specific to the |
|
||||
* opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl() |
|
||||
* interface. |
|
||||
* The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and |
|
||||
* @ref opus_decoderctls may be applied to a multistream encoder or decoder as |
|
||||
* well. |
|
||||
* In addition, you may retrieve the encoder or decoder state for an specific |
|
||||
* stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or |
|
||||
* #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually. |
|
||||
*/ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the encoder state for an individual stream of a multistream encoder.
|
|
||||
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose encoder you |
|
||||
* wish to retrieve. |
|
||||
* This must be non-negative and less than |
|
||||
* the <code>streams</code> parameter used |
|
||||
* to initialize the encoder. |
|
||||
* @param[out] y <tt>OpusEncoder**</tt>: Returns a pointer to the given |
|
||||
* encoder state. |
|
||||
* @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y) |
|
||||
|
|
||||
/** Gets the decoder state for an individual stream of a multistream decoder.
|
|
||||
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose decoder you |
|
||||
* wish to retrieve. |
|
||||
* This must be non-negative and less than |
|
||||
* the <code>streams</code> parameter used |
|
||||
* to initialize the decoder. |
|
||||
* @param[out] y <tt>OpusDecoder**</tt>: Returns a pointer to the given |
|
||||
* decoder state. |
|
||||
* @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_multistream Opus Multistream API
|
|
||||
* @{ |
|
||||
* |
|
||||
* The multistream API allows individual Opus streams to be combined into a |
|
||||
* single packet, enabling support for up to 255 channels. Unlike an |
|
||||
* elementary Opus stream, the encoder and decoder must negotiate the channel |
|
||||
* configuration before the decoder can successfully interpret the data in the |
|
||||
* packets produced by the encoder. Some basic information, such as packet |
|
||||
* duration, can be computed without any special negotiation. |
|
||||
* |
|
||||
* The format for multistream Opus packets is defined in |
|
||||
* <a href="https://tools.ietf.org/html/rfc7845">RFC 7845</a> |
|
||||
* and is based on the self-delimited Opus framing described in Appendix B of |
|
||||
* <a href="https://tools.ietf.org/html/rfc6716">RFC 6716</a>. |
|
||||
* Normal Opus packets are just a degenerate case of multistream Opus packets, |
|
||||
* and can be encoded or decoded with the multistream API by setting |
|
||||
* <code>streams</code> to <code>1</code> when initializing the encoder or |
|
||||
* decoder. |
|
||||
* |
|
||||
* Multistream Opus streams can contain up to 255 elementary Opus streams. |
|
||||
* These may be either "uncoupled" or "coupled", indicating that the decoder |
|
||||
* is configured to decode them to either 1 or 2 channels, respectively. |
|
||||
* The streams are ordered so that all coupled streams appear at the |
|
||||
* beginning. |
|
||||
* |
|
||||
* A <code>mapping</code> table defines which decoded channel <code>i</code> |
|
||||
* should be used for each input/output (I/O) channel <code>j</code>. This table is |
|
||||
* typically provided as an unsigned char array. |
|
||||
* Let <code>i = mapping[j]</code> be the index for I/O channel <code>j</code>. |
|
||||
* If <code>i < 2*coupled_streams</code>, then I/O channel <code>j</code> is |
|
||||
* encoded as the left channel of stream <code>(i/2)</code> if <code>i</code> |
|
||||
* is even, or as the right channel of stream <code>(i/2)</code> if |
|
||||
* <code>i</code> is odd. Otherwise, I/O channel <code>j</code> is encoded as |
|
||||
* mono in stream <code>(i - coupled_streams)</code>, unless it has the special |
|
||||
* value 255, in which case it is omitted from the encoding entirely (the |
|
||||
* decoder will reproduce it as silence). Each value <code>i</code> must either |
|
||||
* be the special value 255 or be less than <code>streams + coupled_streams</code>. |
|
||||
* |
|
||||
* The output channels specified by the encoder |
|
||||
* should use the |
|
||||
* <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis |
|
||||
* channel ordering</a>. A decoder may wish to apply an additional permutation |
|
||||
* to the mapping the encoder used to achieve a different output channel |
|
||||
* order (e.g. for outputing in WAV order). |
|
||||
* |
|
||||
* Each multistream packet contains an Opus packet for each stream, and all of |
|
||||
* the Opus packets in a single multistream packet must have the same |
|
||||
* duration. Therefore the duration of a multistream packet can be extracted |
|
||||
* from the TOC sequence of the first stream, which is located at the |
|
||||
* beginning of the packet, just like an elementary Opus stream: |
|
||||
* |
|
||||
* @code |
|
||||
* int nb_samples; |
|
||||
* int nb_frames; |
|
||||
* nb_frames = opus_packet_get_nb_frames(data, len); |
|
||||
* if (nb_frames < 1) |
|
||||
* return nb_frames; |
|
||||
* nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames; |
|
||||
* @endcode |
|
||||
* |
|
||||
* The general encoding and decoding process proceeds exactly the same as in |
|
||||
* the normal @ref opus_encoder and @ref opus_decoder APIs. |
|
||||
* See their documentation for an overview of how to use the corresponding |
|
||||
* multistream functions. |
|
||||
*/ |
|
||||
|
|
||||
/** Opus multistream encoder state.
|
|
||||
* This contains the complete state of a multistream Opus encoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_multistream_encoder_create |
|
||||
* @see opus_multistream_encoder_init |
|
||||
*/ |
|
||||
typedef struct OpusMSEncoder OpusMSEncoder; |
|
||||
|
|
||||
/** Opus multistream decoder state.
|
|
||||
* This contains the complete state of a multistream Opus decoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_multistream_decoder_create |
|
||||
* @see opus_multistream_decoder_init |
|
||||
*/ |
|
||||
typedef struct OpusMSDecoder OpusMSDecoder; |
|
||||
|
|
||||
/**\name Multistream encoder functions */ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the size of an OpusMSEncoder structure.
|
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @returns The size in bytes on success, or a negative error code |
|
||||
* (see @ref opus_errorcodes) on error. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size( |
|
||||
int streams, |
|
||||
int coupled_streams |
|
||||
); |
|
||||
|
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size( |
|
||||
int channels, |
|
||||
int mapping_family |
|
||||
); |
|
||||
|
|
||||
|
|
||||
/** Allocates and initializes a multistream encoder state.
|
|
||||
* Call opus_multistream_encoder_destroy() to release |
|
||||
* this object when finished. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels in the input signal. |
|
||||
* This must be at most 255. |
|
||||
* It may be greater than the number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than the number of channels. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than the number of input channels. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* encoded channels to input channels, as described in |
|
||||
* @ref opus_multistream. As an extra constraint, the |
|
||||
* multistream encoder does not allow encoding coupled |
|
||||
* streams for which one channel is unused since this |
|
||||
* is never a good idea. |
|
||||
* @param application <tt>int</tt>: The target encoder application. |
|
||||
* This must be one of the following: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
|
||||
* code (see @ref opus_errorcodes) on |
|
||||
* failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int application, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_surround_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int mapping_family, |
|
||||
int *streams, |
|
||||
int *coupled_streams, |
|
||||
unsigned char *mapping, |
|
||||
int application, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
/** Initialize a previously allocated multistream encoder state.
|
|
||||
* The memory pointed to by \a st must be at least the size returned by |
|
||||
* opus_multistream_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of |
|
||||
* malloc. |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @see opus_multistream_encoder_create |
|
||||
* @see opus_multistream_encoder_get_size |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels in the input signal. |
|
||||
* This must be at most 255. |
|
||||
* It may be greater than the number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than the number of channels. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than the number of input channels. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* encoded channels to input channels, as described in |
|
||||
* @ref opus_multistream. As an extra constraint, the |
|
||||
* multistream encoder does not allow encoding coupled |
|
||||
* streams for which one channel is unused since this |
|
||||
* is never a good idea. |
|
||||
* @param application <tt>int</tt>: The target encoder application. |
|
||||
* This must be one of the following: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
|
||||
* on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_encoder_init( |
|
||||
OpusMSEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
OPUS_EXPORT int opus_multistream_surround_encoder_init( |
|
||||
OpusMSEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int mapping_family, |
|
||||
int *streams, |
|
||||
int *coupled_streams, |
|
||||
unsigned char *mapping, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6) OPUS_ARG_NONNULL(7); |
|
||||
|
|
||||
/** Encodes a multistream Opus frame.
|
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved |
|
||||
* samples. |
|
||||
* This must contain |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: Number of samples per channel in the input |
|
||||
* signal. |
|
||||
* This must be an Opus frame size for the |
|
||||
* encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted values |
|
||||
* are 120, 240, 480, 960, 1920, and 2880. |
|
||||
* Passing in a duration of less than 10 ms |
|
||||
* (480 samples at 48 kHz) will prevent the |
|
||||
* encoder from using the LPC or hybrid modes. |
|
||||
* @param[out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode( |
|
||||
OpusMSEncoder *st, |
|
||||
const opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Encodes a multistream Opus frame from floating point input.
|
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param[in] pcm <tt>const float*</tt>: The input signal as interleaved |
|
||||
* samples with a normal range of |
|
||||
* +/-1.0. |
|
||||
* Samples with a range beyond +/-1.0 |
|
||||
* are supported but will be clipped by |
|
||||
* decoders using the integer API and |
|
||||
* should only be used if it is known |
|
||||
* that the far end supports extended |
|
||||
* dynamic range. |
|
||||
* This must contain |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: Number of samples per channel in the input |
|
||||
* signal. |
|
||||
* This must be an Opus frame size for the |
|
||||
* encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted values |
|
||||
* are 120, 240, 480, 960, 1920, and 2880. |
|
||||
* Passing in a duration of less than 10 ms |
|
||||
* (480 samples at 48 kHz) will prevent the |
|
||||
* encoder from using the LPC or hybrid modes. |
|
||||
* @param[out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float( |
|
||||
OpusMSEncoder *st, |
|
||||
const float *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Frees an <code>OpusMSEncoder</code> allocated by
|
|
||||
* opus_multistream_encoder_create(). |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st); |
|
||||
|
|
||||
/** Perform a CTL function on a multistream Opus encoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated by a |
|
||||
* convenience macro. |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls, |
|
||||
* @ref opus_encoderctls, or @ref opus_multistream_ctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_encoderctls |
|
||||
* @see opus_multistream_ctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/**\name Multistream decoder functions */ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the size of an <code>OpusMSDecoder</code> structure.
|
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @returns The size in bytes on success, or a negative error code |
|
||||
* (see @ref opus_errorcodes) on error. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size( |
|
||||
int streams, |
|
||||
int coupled_streams |
|
||||
); |
|
||||
|
|
||||
/** Allocates and initializes a multistream decoder state.
|
|
||||
* Call opus_multistream_decoder_destroy() to release |
|
||||
* this object when finished. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels to output. |
|
||||
* This must be at most 255. |
|
||||
* It may be different from the number of coded |
|
||||
* channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* coded channels to output channels, as described in |
|
||||
* @ref opus_multistream. |
|
||||
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
|
||||
* code (see @ref opus_errorcodes) on |
|
||||
* failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
/** Intialize a previously allocated decoder state object.
|
|
||||
* The memory pointed to by \a st must be at least the size returned by |
|
||||
* opus_multistream_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of |
|
||||
* malloc. |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @see opus_multistream_decoder_create |
|
||||
* @see opus_multistream_deocder_get_size |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels to output. |
|
||||
* This must be at most 255. |
|
||||
* It may be different from the number of coded |
|
||||
* channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* coded channels to output channels, as described in |
|
||||
* @ref opus_multistream. |
|
||||
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
|
||||
* on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_decoder_init( |
|
||||
OpusMSDecoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
/** Decode a multistream Opus packet.
|
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: Input payload. |
|
||||
* Use a <code>NULL</code> |
|
||||
* pointer to indicate packet |
|
||||
* loss. |
|
||||
* @param len <tt>opus_int32</tt>: Number of bytes in payload. |
|
||||
* @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
|
||||
* samples. |
|
||||
* This must contain room for |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: The number of samples per channel of |
|
||||
* available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration |
|
||||
* (120 ms; 5760 for 48kHz), this function will not be capable |
|
||||
* of decoding some packets. In the case of PLC (data==NULL) |
|
||||
* or FEC (decode_fec=1), then frame_size needs to be exactly |
|
||||
* the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the |
|
||||
* next incoming packet. For the PLC and FEC cases, frame_size |
|
||||
* <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
|
||||
* forward error correction data be decoded. |
|
||||
* If no such data is available, the frame is |
|
||||
* decoded as if it were lost. |
|
||||
* @returns Number of samples decoded on success or a negative error code |
|
||||
* (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode( |
|
||||
OpusMSDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Decode a multistream Opus packet with floating point output.
|
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: Input payload. |
|
||||
* Use a <code>NULL</code> |
|
||||
* pointer to indicate packet |
|
||||
* loss. |
|
||||
* @param len <tt>opus_int32</tt>: Number of bytes in payload. |
|
||||
* @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
|
||||
* samples. |
|
||||
* This must contain room for |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: The number of samples per channel of |
|
||||
* available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration |
|
||||
* (120 ms; 5760 for 48kHz), this function will not be capable |
|
||||
* of decoding some packets. In the case of PLC (data==NULL) |
|
||||
* or FEC (decode_fec=1), then frame_size needs to be exactly |
|
||||
* the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the |
|
||||
* next incoming packet. For the PLC and FEC cases, frame_size |
|
||||
* <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
|
||||
* forward error correction data be decoded. |
|
||||
* If no such data is available, the frame is |
|
||||
* decoded as if it were lost. |
|
||||
* @returns Number of samples decoded on success or a negative error code |
|
||||
* (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float( |
|
||||
OpusMSDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
float *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Perform a CTL function on a multistream Opus decoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated by a |
|
||||
* convenience macro. |
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls, |
|
||||
* @ref opus_decoderctls, or @ref opus_multistream_ctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_decoderctls |
|
||||
* @see opus_multistream_ctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Frees an <code>OpusMSDecoder</code> allocated by
|
|
||||
* opus_multistream_decoder_create(). |
|
||||
* @param st <tt>OpusMSDecoder</tt>: Multistream decoder state to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_MULTISTREAM_H */ |
|
||||
@ -1,36 +0,0 @@ |
|||||
//
|
|
||||
// opus_swift.h
|
|
||||
// opus-swift
|
|
||||
//
|
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology
|
|
||||
//
|
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||
// in the Software without restriction, including without limitation the rights
|
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||
// furnished to do so, subject to the following conditions:
|
|
||||
//
|
|
||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||
// copies or substantial portions of the Software.
|
|
||||
//
|
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||
// SOFTWARE.
|
|
||||
//
|
|
||||
|
|
||||
#include <TargetConditionals.h> |
|
||||
|
|
||||
#if TARGET_OS_IPHONE |
|
||||
@import UIKit; |
|
||||
#else |
|
||||
@import AppKit; |
|
||||
#endif |
|
||||
|
|
||||
#include "opus.h" |
|
||||
#include "opus_multistream.h" |
|
||||
|
|
||||
@ -1,166 +0,0 @@ |
|||||
/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */ |
|
||||
/* Modified by Jean-Marc Valin */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
/* opus_types.h based on ogg_types.h from libogg */ |
|
||||
|
|
||||
/**
|
|
||||
@file opus_types.h |
|
||||
@brief Opus reference implementation types |
|
||||
*/ |
|
||||
#ifndef OPUS_TYPES_H |
|
||||
#define OPUS_TYPES_H |
|
||||
|
|
||||
#define opus_int int /* used for counters etc; at least 16 bits */ |
|
||||
#define opus_int64 long long |
|
||||
#define opus_int8 signed char |
|
||||
|
|
||||
#define opus_uint unsigned int /* used for counters etc; at least 16 bits */ |
|
||||
#define opus_uint64 unsigned long long |
|
||||
#define opus_uint8 unsigned char |
|
||||
|
|
||||
/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ |
|
||||
#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) |
|
||||
#include <stdint.h> |
|
||||
# undef opus_int64 |
|
||||
# undef opus_int8 |
|
||||
# undef opus_uint64 |
|
||||
# undef opus_uint8 |
|
||||
typedef int8_t opus_int8; |
|
||||
typedef uint8_t opus_uint8; |
|
||||
typedef int16_t opus_int16; |
|
||||
typedef uint16_t opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef uint32_t opus_uint32; |
|
||||
typedef int64_t opus_int64; |
|
||||
typedef uint64_t opus_uint64; |
|
||||
#elif defined(_WIN32) |
|
||||
|
|
||||
# if defined(__CYGWIN__) |
|
||||
# include <_G_config.h> |
|
||||
typedef _G_int32_t opus_int32; |
|
||||
typedef _G_uint32_t opus_uint32; |
|
||||
typedef _G_int16 opus_int16; |
|
||||
typedef _G_uint16 opus_uint16; |
|
||||
# elif defined(__MINGW32__) |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
# elif defined(__MWERKS__) |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
# else |
|
||||
/* MSVC/Borland */ |
|
||||
typedef __int32 opus_int32; |
|
||||
typedef unsigned __int32 opus_uint32; |
|
||||
typedef __int16 opus_int16; |
|
||||
typedef unsigned __int16 opus_uint16; |
|
||||
# endif |
|
||||
|
|
||||
#elif defined(__MACOS__) |
|
||||
|
|
||||
# include <sys/types.h> |
|
||||
typedef SInt16 opus_int16; |
|
||||
typedef UInt16 opus_uint16; |
|
||||
typedef SInt32 opus_int32; |
|
||||
typedef UInt32 opus_uint32; |
|
||||
|
|
||||
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ |
|
||||
|
|
||||
# include <sys/types.h> |
|
||||
typedef int16_t opus_int16; |
|
||||
typedef u_int16_t opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef u_int32_t opus_uint32; |
|
||||
|
|
||||
#elif defined(__BEOS__) |
|
||||
|
|
||||
/* Be */ |
|
||||
# include <inttypes.h> |
|
||||
typedef int16 opus_int16; |
|
||||
typedef u_int16 opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef u_int32_t opus_uint32; |
|
||||
|
|
||||
#elif defined (__EMX__) |
|
||||
|
|
||||
/* OS/2 GCC */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined (DJGPP) |
|
||||
|
|
||||
/* DJGPP */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined(R5900) |
|
||||
|
|
||||
/* PS2 EE */ |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned opus_uint32; |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
|
|
||||
#elif defined(__SYMBIAN32__) |
|
||||
|
|
||||
/* Symbian GCC */ |
|
||||
typedef signed short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef signed int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) |
|
||||
|
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef long opus_int32; |
|
||||
typedef unsigned long opus_uint32; |
|
||||
|
|
||||
#elif defined(CONFIG_TI_C6X) |
|
||||
|
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#else |
|
||||
|
|
||||
/* Give up, take a reasonable guess */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_TYPES_H */ |
|
||||
@ -1,29 +0,0 @@ |
|||||
// |
|
||||
// module.modulemap |
|
||||
// opus-swift |
|
||||
// |
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
// |
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
// of this software and associated documentation files (the "Software"), to deal |
|
||||
// in the Software without restriction, including without limitation the rights |
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
// copies of the Software, and to permit persons to whom the Software is |
|
||||
// furnished to do so, subject to the following conditions: |
|
||||
// |
|
||||
// The above copyright notice and this permission notice shall be included in all |
|
||||
// copies or substantial portions of the Software. |
|
||||
// |
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||
// SOFTWARE. |
|
||||
// |
|
||||
|
|
||||
framework module YbridOpus { |
|
||||
umbrella header "opus_swift.h" |
|
||||
export * |
|
||||
} |
|
||||
@ -1,43 +0,0 @@ |
|||||
// |
|
||||
// Config.xcconfig |
|
||||
// opus-swift |
|
||||
// |
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
// |
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
// of this software and associated documentation files (the "Software"), to deal |
|
||||
// in the Software without restriction, including without limitation the rights |
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
// copies of the Software, and to permit persons to whom the Software is |
|
||||
// furnished to do so, subject to the following conditions: |
|
||||
// |
|
||||
// The above copyright notice and this permission notice shall be included in all |
|
||||
// copies or substantial portions of the Software. |
|
||||
// |
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||
// SOFTWARE. |
|
||||
// |
|
||||
|
|
||||
// Configuration settings file format documentation can be found at: |
|
||||
// https://help.apple.com/xcode/#/dev745c5c974 |
|
||||
|
|
||||
// Product Version, PLEASE CHANGE HERE to affect all targets |
|
||||
MARKETING_VERSION = 0.8.0 |
|
||||
// Build number, PLEASE CHANGE HERE to affect all targets |
|
||||
CURRENT_PROJECT_VERSION = 3 |
|
||||
|
|
||||
|
|
||||
ARCHS = arm64 armv7 x86_64 x86_64h i386 |
|
||||
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 |
|
||||
EXCLUDED_ARCHS[sdk=macosx*] = i386 |
|
||||
SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx |
|
||||
|
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0 |
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10 |
|
||||
|
|
||||
SWIFT_VERSION = 4.0 |
|
||||
@ -1,59 +0,0 @@ |
|||||
<?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>BuildMachineOSBuild</key> |
|
||||
<string>20G80</string> |
|
||||
<key>CFBundleDevelopmentRegion</key> |
|
||||
<string>de_DE</string> |
|
||||
<key>CFBundleDisplayName</key> |
|
||||
<string>opus-swift</string> |
|
||||
<key>CFBundleExecutable</key> |
|
||||
<string>YbridOpus</string> |
|
||||
<key>CFBundleGetInfoString</key> |
|
||||
<string>libopus wrapper framework for swift</string> |
|
||||
<key>CFBundleIdentifier</key> |
|
||||
<string>io.ybrid.opus-swift</string> |
|
||||
<key>CFBundleInfoDictionaryVersion</key> |
|
||||
<string>6.0</string> |
|
||||
<key>CFBundleName</key> |
|
||||
<string>YbridOpus</string> |
|
||||
<key>CFBundlePackageType</key> |
|
||||
<string>FMWK</string> |
|
||||
<key>CFBundleShortVersionString</key> |
|
||||
<string>0.8.0</string> |
|
||||
<key>CFBundleSupportedPlatforms</key> |
|
||||
<array> |
|
||||
<string>MacOSX</string> |
|
||||
</array> |
|
||||
<key>CFBundleVersion</key> |
|
||||
<string>3</string> |
|
||||
<key>DTCompiler</key> |
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string> |
|
||||
<key>DTPlatformBuild</key> |
|
||||
<string>12E507</string> |
|
||||
<key>DTPlatformName</key> |
|
||||
<string>macosx</string> |
|
||||
<key>DTPlatformVersion</key> |
|
||||
<string>11.3</string> |
|
||||
<key>DTSDKBuild</key> |
|
||||
<string>20E214</string> |
|
||||
<key>DTSDKName</key> |
|
||||
<string>macosx11.3</string> |
|
||||
<key>DTXcode</key> |
|
||||
<string>1251</string> |
|
||||
<key>DTXcodeBuild</key> |
|
||||
<string>12E507</string> |
|
||||
<key>LSApplicationCategoryType</key> |
|
||||
<string>public.app-category.utilities</string> |
|
||||
<key>LSMinimumSystemVersion</key> |
|
||||
<string>10.15</string> |
|
||||
<key>NSHumanReadableCopyright</key> |
|
||||
<string>Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology</string> |
|
||||
<key>UIDeviceFamily</key> |
|
||||
<array> |
|
||||
<integer>2</integer> |
|
||||
<integer>6</integer> |
|
||||
</array> |
|
||||
</dict> |
|
||||
</plist> |
|
||||
Binary file not shown.
@ -1,181 +0,0 @@ |
|||||
<?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>files</key> |
|
||||
<dict> |
|
||||
<key>Resources/Config.xcconfig</key> |
|
||||
<data> |
|
||||
+CifWGfGG+eJ+6RQiR2J6Z9++KM= |
|
||||
</data> |
|
||||
<key>Resources/Info.plist</key> |
|
||||
<data> |
|
||||
IlzGqo/LXxZWT4ERt0gsUyGzn+U= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>files2</key> |
|
||||
<dict> |
|
||||
<key>Headers/opus.h</key> |
|
||||
<dict> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
jPzA/v85IbzDiXG+tLPzcFiknByl2mtZ+0r2OOIfjuY= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_defines.h</key> |
|
||||
<dict> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
9DvrxB739706a104pEEDAbTM24VK2EL+mF6TUjgCRAs= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_multistream.h</key> |
|
||||
<dict> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
G/OMOd/e727v31BLWFvk1IgsAeQcWojBJJlSsQpQDvg= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_swift.h</key> |
|
||||
<dict> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
tU2j9To8QDSbhu8Vz/Lv1Y6uYjEGHp0e5a6RsnGglFM= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_types.h</key> |
|
||||
<dict> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
GcswHqHu28vbtQSTY94GGJO/EcIOUFple2nOb/pbEfo= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Modules/module.modulemap</key> |
|
||||
<dict> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
spkcimiabUAXiltxFizEevGEO4anKye9lDyB981i/XU= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Resources/Config.xcconfig</key> |
|
||||
<dict> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
yWuzbLu2XVuQ/KyJjefCQA6yUIG/ledJEQXfvayiZ78= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Resources/Info.plist</key> |
|
||||
<dict> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
J5Oiy7bLDZsUVvb3DhNYuatBdLPO81ZjS3BTmr9I9eI= |
|
||||
</data> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
<key>rules</key> |
|
||||
<dict> |
|
||||
<key>^Resources/</key> |
|
||||
<true/> |
|
||||
<key>^Resources/.*\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>optional</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1000</real> |
|
||||
</dict> |
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1100</real> |
|
||||
</dict> |
|
||||
<key>^Resources/Base\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>1010</real> |
|
||||
</dict> |
|
||||
<key>^version.plist$</key> |
|
||||
<true/> |
|
||||
</dict> |
|
||||
<key>rules2</key> |
|
||||
<dict> |
|
||||
<key>.*\.dSYM($|/)</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>11</real> |
|
||||
</dict> |
|
||||
<key>^(.*/)?\.DS_Store$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>2000</real> |
|
||||
</dict> |
|
||||
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key> |
|
||||
<dict> |
|
||||
<key>nested</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>10</real> |
|
||||
</dict> |
|
||||
<key>^.*</key> |
|
||||
<true/> |
|
||||
<key>^Info\.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^PkgInfo$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^Resources/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^Resources/.*\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>optional</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1000</real> |
|
||||
</dict> |
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1100</real> |
|
||||
</dict> |
|
||||
<key>^Resources/Base\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>1010</real> |
|
||||
</dict> |
|
||||
<key>^[^/]+$</key> |
|
||||
<dict> |
|
||||
<key>nested</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>10</real> |
|
||||
</dict> |
|
||||
<key>^embedded\.provisionprofile$</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^version\.plist$</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
</plist> |
|
||||
@ -1 +0,0 @@ |
|||||
A |
|
||||
@ -1 +0,0 @@ |
|||||
Versions/Current/YbridOpus |
|
||||
@ -1,43 +0,0 @@ |
|||||
// |
|
||||
// Config.xcconfig |
|
||||
// opus-swift |
|
||||
// |
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
// |
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
// of this software and associated documentation files (the "Software"), to deal |
|
||||
// in the Software without restriction, including without limitation the rights |
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
// copies of the Software, and to permit persons to whom the Software is |
|
||||
// furnished to do so, subject to the following conditions: |
|
||||
// |
|
||||
// The above copyright notice and this permission notice shall be included in all |
|
||||
// copies or substantial portions of the Software. |
|
||||
// |
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||
// SOFTWARE. |
|
||||
// |
|
||||
|
|
||||
// Configuration settings file format documentation can be found at: |
|
||||
// https://help.apple.com/xcode/#/dev745c5c974 |
|
||||
|
|
||||
// Product Version, PLEASE CHANGE HERE to affect all targets |
|
||||
MARKETING_VERSION = 0.8.0 |
|
||||
// Build number, PLEASE CHANGE HERE to affect all targets |
|
||||
CURRENT_PROJECT_VERSION = 3 |
|
||||
|
|
||||
|
|
||||
ARCHS = arm64 armv7 x86_64 x86_64h i386 |
|
||||
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 |
|
||||
EXCLUDED_ARCHS[sdk=macosx*] = i386 |
|
||||
SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx |
|
||||
|
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0 |
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10 |
|
||||
|
|
||||
SWIFT_VERSION = 4.0 |
|
||||
@ -1,981 +0,0 @@ |
|||||
/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
|
|
||||
Written by Jean-Marc Valin and Koen Vos */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus.h |
|
||||
* @brief Opus reference implementation API |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_H |
|
||||
#define OPUS_H |
|
||||
|
|
||||
#include "opus_types.h" |
|
||||
#include "opus_defines.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/**
|
|
||||
* @mainpage Opus |
|
||||
* |
|
||||
* The Opus codec is designed for interactive speech and audio transmission over the Internet. |
|
||||
* It is designed by the IETF Codec Working Group and incorporates technology from |
|
||||
* Skype's SILK codec and Xiph.Org's CELT codec. |
|
||||
* |
|
||||
* The Opus codec is designed to handle a wide range of interactive audio applications, |
|
||||
* including Voice over IP, videoconferencing, in-game chat, and even remote live music |
|
||||
* performances. It can scale from low bit-rate narrowband speech to very high quality |
|
||||
* stereo music. Its main features are: |
|
||||
|
|
||||
* @li Sampling rates from 8 to 48 kHz |
|
||||
* @li Bit-rates from 6 kb/s to 510 kb/s |
|
||||
* @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR) |
|
||||
* @li Audio bandwidth from narrowband to full-band |
|
||||
* @li Support for speech and music |
|
||||
* @li Support for mono and stereo |
|
||||
* @li Support for multichannel (up to 255 channels) |
|
||||
* @li Frame sizes from 2.5 ms to 60 ms |
|
||||
* @li Good loss robustness and packet loss concealment (PLC) |
|
||||
* @li Floating point and fixed-point implementation |
|
||||
* |
|
||||
* Documentation sections: |
|
||||
* @li @ref opus_encoder |
|
||||
* @li @ref opus_decoder |
|
||||
* @li @ref opus_repacketizer |
|
||||
* @li @ref opus_multistream |
|
||||
* @li @ref opus_libinfo |
|
||||
* @li @ref opus_custom |
|
||||
*/ |
|
||||
|
|
||||
/** @defgroup opus_encoder Opus Encoder
|
|
||||
* @{ |
|
||||
* |
|
||||
* @brief This page describes the process and functions used to encode Opus. |
|
||||
* |
|
||||
* Since Opus is a stateful codec, the encoding process starts with creating an encoder |
|
||||
* state. This can be done with: |
|
||||
* |
|
||||
* @code |
|
||||
* int error; |
|
||||
* OpusEncoder *enc; |
|
||||
* enc = opus_encoder_create(Fs, channels, application, &error); |
|
||||
* @endcode |
|
||||
* |
|
||||
* From this point, @c enc can be used for encoding an audio stream. An encoder state |
|
||||
* @b must @b not be used for more than one stream at the same time. Similarly, the encoder |
|
||||
* state @b must @b not be re-initialized for each frame. |
|
||||
* |
|
||||
* While opus_encoder_create() allocates memory for the state, it's also possible |
|
||||
* to initialize pre-allocated memory: |
|
||||
* |
|
||||
* @code |
|
||||
* int size; |
|
||||
* int error; |
|
||||
* OpusEncoder *enc; |
|
||||
* size = opus_encoder_get_size(channels); |
|
||||
* enc = malloc(size); |
|
||||
* error = opus_encoder_init(enc, Fs, channels, application); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where opus_encoder_get_size() returns the required size for the encoder state. Note that |
|
||||
* future versions of this code may change the size, so no assuptions should be made about it. |
|
||||
* |
|
||||
* The encoder state is always continuous in memory and only a shallow copy is sufficient |
|
||||
* to copy it (e.g. memcpy()) |
|
||||
* |
|
||||
* It is possible to change some of the encoder's settings using the opus_encoder_ctl() |
|
||||
* interface. All these settings already default to the recommended value, so they should |
|
||||
* only be changed when necessary. The most common settings one may want to change are: |
|
||||
* |
|
||||
* @code |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate)); |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type)); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where |
|
||||
* |
|
||||
* @arg bitrate is in bits per second (b/s) |
|
||||
* @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest |
|
||||
* @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC |
|
||||
* |
|
||||
* See @ref opus_encoderctls and @ref opus_genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream. |
|
||||
* |
|
||||
* To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data: |
|
||||
* @code |
|
||||
* len = opus_encode(enc, audio_frame, frame_size, packet, max_packet); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where |
|
||||
* <ul> |
|
||||
* <li>audio_frame is the audio data in opus_int16 (or float for opus_encode_float())</li> |
|
||||
* <li>frame_size is the duration of the frame in samples (per channel)</li> |
|
||||
* <li>packet is the byte array to which the compressed data is written</li> |
|
||||
* <li>max_packet is the maximum number of bytes that can be written in the packet (4000 bytes is recommended). |
|
||||
* Do not use max_packet to control VBR target bitrate, instead use the #OPUS_SET_BITRATE CTL.</li> |
|
||||
* </ul> |
|
||||
* |
|
||||
* opus_encode() and opus_encode_float() return the number of bytes actually written to the packet. |
|
||||
* The return value <b>can be negative</b>, which indicates that an error has occurred. If the return value |
|
||||
* is 2 bytes or less, then the packet does not need to be transmitted (DTX). |
|
||||
* |
|
||||
* Once the encoder state if no longer needed, it can be destroyed with |
|
||||
* |
|
||||
* @code |
|
||||
* opus_encoder_destroy(enc); |
|
||||
* @endcode |
|
||||
* |
|
||||
* If the encoder was created with opus_encoder_init() rather than opus_encoder_create(), |
|
||||
* then no action is required aside from potentially freeing the memory that was manually |
|
||||
* allocated for it (calling free(enc) for the example above) |
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
/** Opus encoder state.
|
|
||||
* This contains the complete state of an Opus encoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_encoder_create,opus_encoder_init |
|
||||
*/ |
|
||||
typedef struct OpusEncoder OpusEncoder; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusEncoder</code> structure.
|
|
||||
* @param[in] channels <tt>int</tt>: Number of channels. |
|
||||
* This must be 1 or 2. |
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels); |
|
||||
|
|
||||
/**
|
|
||||
*/ |
|
||||
|
|
||||
/** Allocates and initializes an encoder state.
|
|
||||
* There are three coding modes: |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice |
|
||||
* signals. It enhances the input signal by high-pass filtering and |
|
||||
* emphasizing formants and harmonics. Optionally it includes in-band |
|
||||
* forward error correction to protect against packet loss. Use this |
|
||||
* mode for typical VoIP applications. Because of the enhancement, |
|
||||
* even at high bitrates the output may sound different from the input. |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for most |
|
||||
* non-voice signals like music. Use this mode for music and mixed |
|
||||
* (music/voice) content, broadcast, and applications requiring less |
|
||||
* than 15 ms of coding delay. |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that |
|
||||
* disables the speech-optimized mode in exchange for slightly reduced delay. |
|
||||
* This mode can only be set on an newly initialized or freshly reset encoder |
|
||||
* because it changes the codec delay. |
|
||||
* |
|
||||
* This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution). |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
|
||||
* @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
|
||||
* @param [out] error <tt>int*</tt>: @ref opus_errorcodes |
|
||||
* @note Regardless of the sampling rate and number channels selected, the Opus encoder |
|
||||
* can switch to a lower audio bandwidth or number of channels if the bitrate |
|
||||
* selected is too low. This also means that it is safe to always use 48 kHz stereo input |
|
||||
* and let the encoder optimize the encoding. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int application, |
|
||||
int *error |
|
||||
); |
|
||||
|
|
||||
/** Initializes a previously allocated encoder state
|
|
||||
* The memory pointed to by st must be at least the size returned by opus_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of malloc. |
|
||||
* @see opus_encoder_create(),opus_encoder_get_size() |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
|
||||
* @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
|
||||
* @retval #OPUS_OK Success or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_encoder_init( |
|
||||
OpusEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Encodes an Opus frame.
|
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16) |
|
||||
* @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
|
||||
* input signal. |
|
||||
* This must be an Opus frame size for |
|
||||
* the encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted |
|
||||
* values are 120, 240, 480, 960, 1920, |
|
||||
* and 2880. |
|
||||
* Passing in a duration of less than |
|
||||
* 10 ms (480 samples at 48 kHz) will |
|
||||
* prevent the encoder from using the LPC |
|
||||
* or hybrid modes. |
|
||||
* @param [out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode( |
|
||||
OpusEncoder *st, |
|
||||
const opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Encodes an Opus frame from floating point input.
|
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] pcm <tt>float*</tt>: Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. |
|
||||
* Samples with a range beyond +/-1.0 are supported but will |
|
||||
* be clipped by decoders using the integer API and should |
|
||||
* only be used if it is known that the far end supports |
|
||||
* extended dynamic range. |
|
||||
* length is frame_size*channels*sizeof(float) |
|
||||
* @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
|
||||
* input signal. |
|
||||
* This must be an Opus frame size for |
|
||||
* the encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted |
|
||||
* values are 120, 240, 480, 960, 1920, |
|
||||
* and 2880. |
|
||||
* Passing in a duration of less than |
|
||||
* 10 ms (480 samples at 48 kHz) will |
|
||||
* prevent the encoder from using the LPC |
|
||||
* or hybrid modes. |
|
||||
* @param [out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float( |
|
||||
OpusEncoder *st, |
|
||||
const float *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Frees an <code>OpusEncoder</code> allocated by opus_encoder_create().
|
|
||||
* @param[in] st <tt>OpusEncoder*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st); |
|
||||
|
|
||||
/** Perform a CTL function on an Opus encoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated |
|
||||
* by a convenience macro. |
|
||||
* @param st <tt>OpusEncoder*</tt>: Encoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls or |
|
||||
* @ref opus_encoderctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_encoderctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_decoder Opus Decoder
|
|
||||
* @{ |
|
||||
* |
|
||||
* @brief This page describes the process and functions used to decode Opus. |
|
||||
* |
|
||||
* The decoding process also starts with creating a decoder |
|
||||
* state. This can be done with: |
|
||||
* @code |
|
||||
* int error; |
|
||||
* OpusDecoder *dec; |
|
||||
* dec = opus_decoder_create(Fs, channels, &error); |
|
||||
* @endcode |
|
||||
* where |
|
||||
* @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000 |
|
||||
* @li channels is the number of channels (1 or 2) |
|
||||
* @li error will hold the error code in case of failure (or #OPUS_OK on success) |
|
||||
* @li the return value is a newly created decoder state to be used for decoding |
|
||||
* |
|
||||
* While opus_decoder_create() allocates memory for the state, it's also possible |
|
||||
* to initialize pre-allocated memory: |
|
||||
* @code |
|
||||
* int size; |
|
||||
* int error; |
|
||||
* OpusDecoder *dec; |
|
||||
* size = opus_decoder_get_size(channels); |
|
||||
* dec = malloc(size); |
|
||||
* error = opus_decoder_init(dec, Fs, channels); |
|
||||
* @endcode |
|
||||
* where opus_decoder_get_size() returns the required size for the decoder state. Note that |
|
||||
* future versions of this code may change the size, so no assuptions should be made about it. |
|
||||
* |
|
||||
* The decoder state is always continuous in memory and only a shallow copy is sufficient |
|
||||
* to copy it (e.g. memcpy()) |
|
||||
* |
|
||||
* To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data: |
|
||||
* @code |
|
||||
* frame_size = opus_decode(dec, packet, len, decoded, max_size, 0); |
|
||||
* @endcode |
|
||||
* where |
|
||||
* |
|
||||
* @li packet is the byte array containing the compressed data |
|
||||
* @li len is the exact number of bytes contained in the packet |
|
||||
* @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float()) |
|
||||
* @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array |
|
||||
* |
|
||||
* opus_decode() and opus_decode_float() return the number of samples (per channel) decoded from the packet. |
|
||||
* If that value is negative, then an error has occurred. This can occur if the packet is corrupted or if the audio |
|
||||
* buffer is too small to hold the decoded audio. |
|
||||
* |
|
||||
* Opus is a stateful codec with overlapping blocks and as a result Opus |
|
||||
* packets are not coded independently of each other. Packets must be |
|
||||
* passed into the decoder serially and in the correct order for a correct |
|
||||
* decode. Lost packets can be replaced with loss concealment by calling |
|
||||
* the decoder with a null pointer and zero length for the missing packet. |
|
||||
* |
|
||||
* A single codec state may only be accessed from a single thread at |
|
||||
* a time and any required locking must be performed by the caller. Separate |
|
||||
* streams must be decoded with separate decoder states and can be decoded |
|
||||
* in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK |
|
||||
* defined. |
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
/** Opus decoder state.
|
|
||||
* This contains the complete state of an Opus decoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_decoder_create,opus_decoder_init |
|
||||
*/ |
|
||||
typedef struct OpusDecoder OpusDecoder; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusDecoder</code> structure.
|
|
||||
* @param [in] channels <tt>int</tt>: Number of channels. |
|
||||
* This must be 1 or 2. |
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels); |
|
||||
|
|
||||
/** Allocates and initializes a decoder state.
|
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sample rate to decode at (Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
|
||||
* @param [out] error <tt>int*</tt>: #OPUS_OK Success or @ref opus_errorcodes |
|
||||
* |
|
||||
* Internally Opus stores data at 48000 Hz, so that should be the default |
|
||||
* value for Fs. However, the decoder can efficiently decode to buffers |
|
||||
* at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use |
|
||||
* data at the full sample rate, or knows the compressed data doesn't |
|
||||
* use the full frequency range, it can request decoding at a reduced |
|
||||
* rate. Likewise, the decoder is capable of filling in either mono or |
|
||||
* interleaved stereo pcm buffers, at the caller's request. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int *error |
|
||||
); |
|
||||
|
|
||||
/** Initializes a previously allocated decoder state.
|
|
||||
* The state must be at least the size returned by opus_decoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state. |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate to decode to (Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
|
||||
* @retval #OPUS_OK Success or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_decoder_init( |
|
||||
OpusDecoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels |
|
||||
) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Decode an Opus packet.
|
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
|
||||
* @param [in] len <tt>opus_int32</tt>: Number of bytes in payload* |
|
||||
* @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length |
|
||||
* is frame_size*channels*sizeof(opus_int16) |
|
||||
* @param [in] frame_size Number of samples per channel of available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
|
||||
* not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
|
||||
* then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
|
||||
* FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
|
||||
* decoded. If no such data is available, the frame is decoded as if it were lost. |
|
||||
* @returns Number of decoded samples or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode( |
|
||||
OpusDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Decode an Opus packet with floating point output.
|
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
|
||||
* @param [in] len <tt>opus_int32</tt>: Number of bytes in payload |
|
||||
* @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length |
|
||||
* is frame_size*channels*sizeof(float) |
|
||||
* @param [in] frame_size Number of samples per channel of available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
|
||||
* not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
|
||||
* then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
|
||||
* FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
|
||||
* decoded. If no such data is available the frame is decoded as if it were lost. |
|
||||
* @returns Number of decoded samples or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float( |
|
||||
OpusDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
float *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Perform a CTL function on an Opus decoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated |
|
||||
* by a convenience macro. |
|
||||
* @param st <tt>OpusDecoder*</tt>: Decoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls or |
|
||||
* @ref opus_decoderctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_decoderctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Frees an <code>OpusDecoder</code> allocated by opus_decoder_create().
|
|
||||
* @param[in] st <tt>OpusDecoder*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st); |
|
||||
|
|
||||
/** Parse an opus packet into one or more frames.
|
|
||||
* Opus_decode will perform this operation internally so most applications do |
|
||||
* not need to use this function. |
|
||||
* This function does not copy the frames, the returned pointers are pointers into |
|
||||
* the input packet. |
|
||||
* @param [in] data <tt>char*</tt>: Opus packet to be parsed |
|
||||
* @param [in] len <tt>opus_int32</tt>: size of data |
|
||||
* @param [out] out_toc <tt>char*</tt>: TOC pointer |
|
||||
* @param [out] frames <tt>char*[48]</tt> encapsulated frames |
|
||||
* @param [out] size <tt>opus_int16[48]</tt> sizes of the encapsulated frames |
|
||||
* @param [out] payload_offset <tt>int*</tt>: returns the position of the payload within the packet (in bytes) |
|
||||
* @returns number of frames |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_packet_parse( |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
unsigned char *out_toc, |
|
||||
const unsigned char *frames[48], |
|
||||
opus_int16 size[48], |
|
||||
int *payload_offset |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
/** Gets the bandwidth of an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet |
|
||||
* @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples per frame from an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet. |
|
||||
* This must contain at least one byte of |
|
||||
* data. |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
|
||||
* This must be a multiple of 400, or |
|
||||
* inaccurate results will be returned. |
|
||||
* @returns Number of samples per frame. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of channels from an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet |
|
||||
* @returns Number of channels |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of frames in an Opus packet.
|
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @returns Number of frames |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples of an Opus packet.
|
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
|
||||
* This must be a multiple of 400, or |
|
||||
* inaccurate results will be returned. |
|
||||
* @returns Number of samples |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples of an Opus packet.
|
|
||||
* @param [in] dec <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @returns Number of samples |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
|
||||
|
|
||||
/** Applies soft-clipping to bring a float signal within the [-1,1] range. If
|
|
||||
* the signal is already in that range, nothing is done. If there are values |
|
||||
* outside of [-1,1], then the signal is clipped as smoothly as possible to |
|
||||
* both fit in the range and avoid creating excessive distortion in the |
|
||||
* process. |
|
||||
* @param [in,out] pcm <tt>float*</tt>: Input PCM and modified PCM |
|
||||
* @param [in] frame_size <tt>int</tt> Number of samples per channel to process |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels |
|
||||
* @param [in,out] softclip_mem <tt>float*</tt>: State memory for the soft clipping process (one float per channel, initialized to zero) |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem); |
|
||||
|
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_repacketizer Repacketizer
|
|
||||
* @{ |
|
||||
* |
|
||||
* The repacketizer can be used to merge multiple Opus packets into a single |
|
||||
* packet or alternatively to split Opus packets that have previously been |
|
||||
* merged. Splitting valid Opus packets is always guaranteed to succeed, |
|
||||
* whereas merging valid packets only succeeds if all frames have the same |
|
||||
* mode, bandwidth, and frame size, and when the total duration of the merged |
|
||||
* packet is no more than 120 ms. The 120 ms limit comes from the |
|
||||
* specification and limits decoder memory requirements at a point where |
|
||||
* framing overhead becomes negligible. |
|
||||
* |
|
||||
* The repacketizer currently only operates on elementary Opus |
|
||||
* streams. It will not manipualte multistream packets successfully, except in |
|
||||
* the degenerate case where they consist of data from a single stream. |
|
||||
* |
|
||||
* The repacketizing process starts with creating a repacketizer state, either |
|
||||
* by calling opus_repacketizer_create() or by allocating the memory yourself, |
|
||||
* e.g., |
|
||||
* @code |
|
||||
* OpusRepacketizer *rp; |
|
||||
* rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size()); |
|
||||
* if (rp != NULL) |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* @endcode |
|
||||
* |
|
||||
* Then the application should submit packets with opus_repacketizer_cat(), |
|
||||
* extract new packets with opus_repacketizer_out() or |
|
||||
* opus_repacketizer_out_range(), and then reset the state for the next set of |
|
||||
* input packets via opus_repacketizer_init(). |
|
||||
* |
|
||||
* For example, to split a sequence of packets into individual frames: |
|
||||
* @code |
|
||||
* unsigned char *data; |
|
||||
* int len; |
|
||||
* while (get_next_packet(&data, &len)) |
|
||||
* { |
|
||||
* unsigned char out[1276]; |
|
||||
* opus_int32 out_len; |
|
||||
* int nb_frames; |
|
||||
* int err; |
|
||||
* int i; |
|
||||
* err = opus_repacketizer_cat(rp, data, len); |
|
||||
* if (err != OPUS_OK) |
|
||||
* { |
|
||||
* release_packet(data); |
|
||||
* return err; |
|
||||
* } |
|
||||
* nb_frames = opus_repacketizer_get_nb_frames(rp); |
|
||||
* for (i = 0; i < nb_frames; i++) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out)); |
|
||||
* if (out_len < 0) |
|
||||
* { |
|
||||
* release_packet(data); |
|
||||
* return (int)out_len; |
|
||||
* } |
|
||||
* output_next_packet(out, out_len); |
|
||||
* } |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* release_packet(data); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* Alternatively, to combine a sequence of frames into packets that each |
|
||||
* contain up to <code>TARGET_DURATION_MS</code> milliseconds of data: |
|
||||
* @code |
|
||||
* // The maximum number of packets with duration TARGET_DURATION_MS occurs
|
|
||||
* // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5)
|
|
||||
* // packets.
|
|
||||
* unsigned char *data[(TARGET_DURATION_MS*2/5)+1]; |
|
||||
* opus_int32 len[(TARGET_DURATION_MS*2/5)+1]; |
|
||||
* int nb_packets; |
|
||||
* unsigned char out[1277*(TARGET_DURATION_MS*2/2)]; |
|
||||
* opus_int32 out_len; |
|
||||
* int prev_toc; |
|
||||
* nb_packets = 0; |
|
||||
* while (get_next_packet(data+nb_packets, len+nb_packets)) |
|
||||
* { |
|
||||
* int nb_frames; |
|
||||
* int err; |
|
||||
* nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]); |
|
||||
* if (nb_frames < 1) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return nb_frames; |
|
||||
* } |
|
||||
* nb_frames += opus_repacketizer_get_nb_frames(rp); |
|
||||
* // If adding the next packet would exceed our target, or it has an
|
|
||||
* // incompatible TOC sequence, output the packets we already have before
|
|
||||
* // submitting it.
|
|
||||
* // N.B., The nb_packets > 0 check ensures we've submitted at least one
|
|
||||
* // packet since the last call to opus_repacketizer_init(). Otherwise a
|
|
||||
* // single packet longer than TARGET_DURATION_MS would cause us to try to
|
|
||||
* // output an (invalid) empty packet. It also ensures that prev_toc has
|
|
||||
* // been set to a valid value. Additionally, len[nb_packets] > 0 is
|
|
||||
* // guaranteed by the call to opus_packet_get_nb_frames() above, so the
|
|
||||
* // reference to data[nb_packets][0] should be valid.
|
|
||||
* if (nb_packets > 0 && ( |
|
||||
* ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) || |
|
||||
* opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames > |
|
||||
* TARGET_DURATION_MS*48)) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
|
||||
* if (out_len < 0) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return (int)out_len; |
|
||||
* } |
|
||||
* output_next_packet(out, out_len); |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* release_packets(data, nb_packets); |
|
||||
* data[0] = data[nb_packets]; |
|
||||
* len[0] = len[nb_packets]; |
|
||||
* nb_packets = 0; |
|
||||
* } |
|
||||
* err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]); |
|
||||
* if (err != OPUS_OK) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return err; |
|
||||
* } |
|
||||
* prev_toc = data[nb_packets][0]; |
|
||||
* nb_packets++; |
|
||||
* } |
|
||||
* // Output the final, partial packet.
|
|
||||
* if (nb_packets > 0) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
|
||||
* release_packets(data, nb_packets); |
|
||||
* if (out_len < 0) |
|
||||
* return (int)out_len; |
|
||||
* output_next_packet(out, out_len); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* An alternate way of merging packets is to simply call opus_repacketizer_cat() |
|
||||
* unconditionally until it fails. At that point, the merged packet can be |
|
||||
* obtained with opus_repacketizer_out() and the input packet for which |
|
||||
* opus_repacketizer_cat() needs to be re-added to a newly reinitialized |
|
||||
* repacketizer state. |
|
||||
*/ |
|
||||
|
|
||||
typedef struct OpusRepacketizer OpusRepacketizer; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusRepacketizer</code> structure.
|
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void); |
|
||||
|
|
||||
/** (Re)initializes a previously allocated repacketizer state.
|
|
||||
* The state must be at least the size returned by opus_repacketizer_get_size(). |
|
||||
* This can be used for applications which use their own allocator instead of |
|
||||
* malloc(). |
|
||||
* It must also be called to reset the queue of packets waiting to be |
|
||||
* repacketized, which is necessary if the maximum packet duration of 120 ms |
|
||||
* is reached or if you wish to submit packets with a different Opus |
|
||||
* configuration (coding mode, audio bandwidth, frame size, or channel count). |
|
||||
* Failure to do so will prevent a new packet from being added with |
|
||||
* opus_repacketizer_cat(). |
|
||||
* @see opus_repacketizer_create |
|
||||
* @see opus_repacketizer_get_size |
|
||||
* @see opus_repacketizer_cat |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to |
|
||||
* (re)initialize. |
|
||||
* @returns A pointer to the same repacketizer state that was passed in. |
|
||||
*/ |
|
||||
OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Allocates memory and initializes the new repacketizer with
|
|
||||
* opus_repacketizer_init(). |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void); |
|
||||
|
|
||||
/** Frees an <code>OpusRepacketizer</code> allocated by
|
|
||||
* opus_repacketizer_create(). |
|
||||
* @param[in] rp <tt>OpusRepacketizer*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp); |
|
||||
|
|
||||
/** Add a packet to the current repacketizer state.
|
|
||||
* This packet must match the configuration of any packets already submitted |
|
||||
* for repacketization since the last call to opus_repacketizer_init(). |
|
||||
* This means that it must have the same coding mode, audio bandwidth, frame |
|
||||
* size, and channel count. |
|
||||
* This can be checked in advance by examining the top 6 bits of the first |
|
||||
* byte of the packet, and ensuring they match the top 6 bits of the first |
|
||||
* byte of any previously submitted packet. |
|
||||
* The total duration of audio in the repacketizer state also must not exceed |
|
||||
* 120 ms, the maximum duration of a single packet, after adding this packet. |
|
||||
* |
|
||||
* The contents of the current repacketizer state can be extracted into new |
|
||||
* packets using opus_repacketizer_out() or opus_repacketizer_out_range(). |
|
||||
* |
|
||||
* In order to add a packet with a different configuration or to add more |
|
||||
* audio beyond 120 ms, you must clear the repacketizer state by calling |
|
||||
* opus_repacketizer_init(). |
|
||||
* If a packet is too large to add to the current repacketizer state, no part |
|
||||
* of it is added, even if it contains multiple frames, some of which might |
|
||||
* fit. |
|
||||
* If you wish to be able to add parts of such packets, you should first use |
|
||||
* another repacketizer to split the packet into pieces and add them |
|
||||
* individually. |
|
||||
* @see opus_repacketizer_out_range |
|
||||
* @see opus_repacketizer_out |
|
||||
* @see opus_repacketizer_init |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to which to |
|
||||
* add the packet. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: The packet data. |
|
||||
* The application must ensure |
|
||||
* this pointer remains valid |
|
||||
* until the next call to |
|
||||
* opus_repacketizer_init() or |
|
||||
* opus_repacketizer_destroy(). |
|
||||
* @param len <tt>opus_int32</tt>: The number of bytes in the packet data. |
|
||||
* @returns An error code indicating whether or not the operation succeeded. |
|
||||
* @retval #OPUS_OK The packet's contents have been added to the repacketizer |
|
||||
* state. |
|
||||
* @retval #OPUS_INVALID_PACKET The packet did not have a valid TOC sequence, |
|
||||
* the packet's TOC sequence was not compatible |
|
||||
* with previously submitted packets (because |
|
||||
* the coding mode, audio bandwidth, frame size, |
|
||||
* or channel count did not match), or adding |
|
||||
* this packet would increase the total amount of |
|
||||
* audio stored in the repacketizer state to more |
|
||||
* than 120 ms. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
|
||||
|
|
||||
|
|
||||
/** Construct a new packet from data previously submitted to the repacketizer
|
|
||||
* state via opus_repacketizer_cat(). |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
|
||||
* construct the new packet. |
|
||||
* @param begin <tt>int</tt>: The index of the first frame in the current |
|
||||
* repacketizer state to include in the output. |
|
||||
* @param end <tt>int</tt>: One past the index of the last frame in the |
|
||||
* current repacketizer state to include in the |
|
||||
* output. |
|
||||
* @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
|
||||
* store the output packet. |
|
||||
* @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
|
||||
* the output buffer. In order to guarantee |
|
||||
* success, this should be at least |
|
||||
* <code>1276</code> for a single frame, |
|
||||
* or for multiple frames, |
|
||||
* <code>1277*(end-begin)</code>. |
|
||||
* However, <code>1*(end-begin)</code> plus |
|
||||
* the size of all packet data submitted to |
|
||||
* the repacketizer since the last call to |
|
||||
* opus_repacketizer_init() or |
|
||||
* opus_repacketizer_create() is also |
|
||||
* sufficient, and possibly much smaller. |
|
||||
* @returns The total size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG <code>[begin,end)</code> was an invalid range of |
|
||||
* frames (begin < 0, begin >= end, or end > |
|
||||
* opus_repacketizer_get_nb_frames()). |
|
||||
* @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
|
||||
* complete output packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Return the total number of frames contained in packet data submitted to
|
|
||||
* the repacketizer state so far via opus_repacketizer_cat() since the last |
|
||||
* call to opus_repacketizer_init() or opus_repacketizer_create(). |
|
||||
* This defines the valid range of packets that can be extracted with |
|
||||
* opus_repacketizer_out_range() or opus_repacketizer_out(). |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state containing the |
|
||||
* frames. |
|
||||
* @returns The total number of frames contained in the packet data submitted |
|
||||
* to the repacketizer state. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Construct a new packet from data previously submitted to the repacketizer
|
|
||||
* state via opus_repacketizer_cat(). |
|
||||
* This is a convenience routine that returns all the data submitted so far |
|
||||
* in a single packet. |
|
||||
* It is equivalent to calling |
|
||||
* @code |
|
||||
* opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp), |
|
||||
* data, maxlen) |
|
||||
* @endcode |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
|
||||
* construct the new packet. |
|
||||
* @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
|
||||
* store the output packet. |
|
||||
* @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
|
||||
* the output buffer. In order to guarantee |
|
||||
* success, this should be at least |
|
||||
* <code>1277*opus_repacketizer_get_nb_frames(rp)</code>. |
|
||||
* However, |
|
||||
* <code>1*opus_repacketizer_get_nb_frames(rp)</code> |
|
||||
* plus the size of all packet data |
|
||||
* submitted to the repacketizer since the |
|
||||
* last call to opus_repacketizer_init() or |
|
||||
* opus_repacketizer_create() is also |
|
||||
* sufficient, and possibly much smaller. |
|
||||
* @returns The total size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
|
||||
* complete output packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Pads a given Opus packet to a larger size (possibly changing the TOC sequence).
|
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to pad. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
|
||||
* This must be at least as large as len. |
|
||||
* @returns an error code |
|
||||
* @retval #OPUS_OK \a on success. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len); |
|
||||
|
|
||||
/** Remove all padding from a given Opus packet and rewrite the TOC sequence to
|
|
||||
* minimize space usage. |
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to strip. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @returns The new size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len); |
|
||||
|
|
||||
/** Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence).
|
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to pad. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
|
||||
* This must be at least 1. |
|
||||
* @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
|
||||
* This must be at least as large as len. |
|
||||
* @returns an error code |
|
||||
* @retval #OPUS_OK \a on success. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams); |
|
||||
|
|
||||
/** Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to
|
|
||||
* minimize space usage. |
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to strip. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
|
||||
* This must be at least 1. |
|
||||
* @returns The new size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_H */ |
|
||||
@ -1,799 +0,0 @@ |
|||||
/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
|
|
||||
Written by Jean-Marc Valin and Koen Vos */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus_defines.h |
|
||||
* @brief Opus reference implementation constants |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_DEFINES_H |
|
||||
#define OPUS_DEFINES_H |
|
||||
|
|
||||
#include "opus_types.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/** @defgroup opus_errorcodes Error codes
|
|
||||
* @{ |
|
||||
*/ |
|
||||
/** No error @hideinitializer*/ |
|
||||
#define OPUS_OK 0 |
|
||||
/** One or more invalid/out of range arguments @hideinitializer*/ |
|
||||
#define OPUS_BAD_ARG -1 |
|
||||
/** Not enough bytes allocated in the buffer @hideinitializer*/ |
|
||||
#define OPUS_BUFFER_TOO_SMALL -2 |
|
||||
/** An internal error was detected @hideinitializer*/ |
|
||||
#define OPUS_INTERNAL_ERROR -3 |
|
||||
/** The compressed data passed is corrupted @hideinitializer*/ |
|
||||
#define OPUS_INVALID_PACKET -4 |
|
||||
/** Invalid/unsupported request number @hideinitializer*/ |
|
||||
#define OPUS_UNIMPLEMENTED -5 |
|
||||
/** An encoder or decoder structure is invalid or already freed @hideinitializer*/ |
|
||||
#define OPUS_INVALID_STATE -6 |
|
||||
/** Memory allocation has failed @hideinitializer*/ |
|
||||
#define OPUS_ALLOC_FAIL -7 |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @cond OPUS_INTERNAL_DOC */ |
|
||||
/**Export control for opus functions */ |
|
||||
|
|
||||
#ifndef OPUS_EXPORT |
|
||||
# if defined(WIN32) |
|
||||
# if defined(OPUS_BUILD) && defined(DLL_EXPORT) |
|
||||
# define OPUS_EXPORT __declspec(dllexport) |
|
||||
# else |
|
||||
# define OPUS_EXPORT |
|
||||
# endif |
|
||||
# elif defined(__GNUC__) && defined(OPUS_BUILD) |
|
||||
# define OPUS_EXPORT __attribute__ ((visibility ("default"))) |
|
||||
# else |
|
||||
# define OPUS_EXPORT |
|
||||
# endif |
|
||||
#endif |
|
||||
|
|
||||
# if !defined(OPUS_GNUC_PREREQ) |
|
||||
# if defined(__GNUC__)&&defined(__GNUC_MINOR__) |
|
||||
# define OPUS_GNUC_PREREQ(_maj,_min) \ |
|
||||
((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) |
|
||||
# else |
|
||||
# define OPUS_GNUC_PREREQ(_maj,_min) 0 |
|
||||
# endif |
|
||||
# endif |
|
||||
|
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
|
||||
# if OPUS_GNUC_PREREQ(3,0) |
|
||||
# define OPUS_RESTRICT __restrict__ |
|
||||
# elif (defined(_MSC_VER) && _MSC_VER >= 1400) |
|
||||
# define OPUS_RESTRICT __restrict |
|
||||
# else |
|
||||
# define OPUS_RESTRICT |
|
||||
# endif |
|
||||
#else |
|
||||
# define OPUS_RESTRICT restrict |
|
||||
#endif |
|
||||
|
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
|
||||
# if OPUS_GNUC_PREREQ(2,7) |
|
||||
# define OPUS_INLINE __inline__ |
|
||||
# elif (defined(_MSC_VER)) |
|
||||
# define OPUS_INLINE __inline |
|
||||
# else |
|
||||
# define OPUS_INLINE |
|
||||
# endif |
|
||||
#else |
|
||||
# define OPUS_INLINE inline |
|
||||
#endif |
|
||||
|
|
||||
/**Warning attributes for opus functions
|
|
||||
* NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out |
|
||||
* some paranoid null checks. */ |
|
||||
#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
|
||||
# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) |
|
||||
#else |
|
||||
# define OPUS_WARN_UNUSED_RESULT |
|
||||
#endif |
|
||||
#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
|
||||
# define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) |
|
||||
#else |
|
||||
# define OPUS_ARG_NONNULL(_x) |
|
||||
#endif |
|
||||
|
|
||||
/** These are the actual Encoder CTL ID numbers.
|
|
||||
* They should not be used directly by applications. |
|
||||
* In general, SETs should be even and GETs should be odd.*/ |
|
||||
#define OPUS_SET_APPLICATION_REQUEST 4000 |
|
||||
#define OPUS_GET_APPLICATION_REQUEST 4001 |
|
||||
#define OPUS_SET_BITRATE_REQUEST 4002 |
|
||||
#define OPUS_GET_BITRATE_REQUEST 4003 |
|
||||
#define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 |
|
||||
#define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 |
|
||||
#define OPUS_SET_VBR_REQUEST 4006 |
|
||||
#define OPUS_GET_VBR_REQUEST 4007 |
|
||||
#define OPUS_SET_BANDWIDTH_REQUEST 4008 |
|
||||
#define OPUS_GET_BANDWIDTH_REQUEST 4009 |
|
||||
#define OPUS_SET_COMPLEXITY_REQUEST 4010 |
|
||||
#define OPUS_GET_COMPLEXITY_REQUEST 4011 |
|
||||
#define OPUS_SET_INBAND_FEC_REQUEST 4012 |
|
||||
#define OPUS_GET_INBAND_FEC_REQUEST 4013 |
|
||||
#define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 |
|
||||
#define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 |
|
||||
#define OPUS_SET_DTX_REQUEST 4016 |
|
||||
#define OPUS_GET_DTX_REQUEST 4017 |
|
||||
#define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 |
|
||||
#define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 |
|
||||
#define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 |
|
||||
#define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 |
|
||||
#define OPUS_SET_SIGNAL_REQUEST 4024 |
|
||||
#define OPUS_GET_SIGNAL_REQUEST 4025 |
|
||||
#define OPUS_GET_LOOKAHEAD_REQUEST 4027 |
|
||||
/* #define OPUS_RESET_STATE 4028 */ |
|
||||
#define OPUS_GET_SAMPLE_RATE_REQUEST 4029 |
|
||||
#define OPUS_GET_FINAL_RANGE_REQUEST 4031 |
|
||||
#define OPUS_GET_PITCH_REQUEST 4033 |
|
||||
#define OPUS_SET_GAIN_REQUEST 4034 |
|
||||
#define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */ |
|
||||
#define OPUS_SET_LSB_DEPTH_REQUEST 4036 |
|
||||
#define OPUS_GET_LSB_DEPTH_REQUEST 4037 |
|
||||
#define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039 |
|
||||
#define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040 |
|
||||
#define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041 |
|
||||
#define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042 |
|
||||
#define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043 |
|
||||
/* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */ |
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046 |
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047 |
|
||||
#define OPUS_GET_IN_DTX_REQUEST 4049 |
|
||||
|
|
||||
/** Defines for the presence of extended APIs. */ |
|
||||
#define OPUS_HAVE_OPUS_PROJECTION_H |
|
||||
|
|
||||
/* Macros to trigger compilation errors when the wrong types are provided to a CTL */ |
|
||||
#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) |
|
||||
#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) |
|
||||
#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) |
|
||||
#define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr))) |
|
||||
/** @endcond */ |
|
||||
|
|
||||
/** @defgroup opus_ctlvalues Pre-defined values for CTL interface
|
|
||||
* @see opus_genericctls, opus_encoderctls |
|
||||
* @{ |
|
||||
*/ |
|
||||
/* Values for the various encoder CTLs */ |
|
||||
#define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/ |
|
||||
#define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/ |
|
||||
|
|
||||
/** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_VOIP 2048 |
|
||||
/** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_AUDIO 2049 |
|
||||
/** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 |
|
||||
|
|
||||
#define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */ |
|
||||
#define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */ |
|
||||
#define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hideinitializer*/ |
|
||||
|
|
||||
#define OPUS_FRAMESIZE_ARG 5000 /**< Select frame size from the argument (default) */ |
|
||||
#define OPUS_FRAMESIZE_2_5_MS 5001 /**< Use 2.5 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_5_MS 5002 /**< Use 5 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_10_MS 5003 /**< Use 10 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_20_MS 5004 /**< Use 20 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_40_MS 5005 /**< Use 40 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_60_MS 5006 /**< Use 60 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_80_MS 5007 /**< Use 80 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_100_MS 5008 /**< Use 100 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_120_MS 5009 /**< Use 120 ms frames */ |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
|
|
||||
/** @defgroup opus_encoderctls Encoder related CTLs
|
|
||||
* |
|
||||
* These are convenience macros for use with the \c opus_encode_ctl |
|
||||
* interface. They are used to generate the appropriate series of |
|
||||
* arguments for that call, passing the correct type, size and so |
|
||||
* on as expected for each particular request. |
|
||||
* |
|
||||
* Some usage examples: |
|
||||
* |
|
||||
* @code |
|
||||
* int ret; |
|
||||
* ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); |
|
||||
* if (ret != OPUS_OK) return ret; |
|
||||
* |
|
||||
* opus_int32 rate; |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); |
|
||||
* |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
|
||||
* @endcode |
|
||||
* |
|
||||
* @see opus_genericctls, opus_encoder |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Configures the encoder's computational complexity.
|
|
||||
* The supported range is 0-10 inclusive with 10 representing the highest complexity. |
|
||||
* @see OPUS_GET_COMPLEXITY |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive. |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's complexity configuration.
|
|
||||
* @see OPUS_SET_COMPLEXITY |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10, |
|
||||
* inclusive. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the bitrate in the encoder.
|
|
||||
* Rates from 500 to 512000 bits per second are meaningful, as well as the |
|
||||
* special values #OPUS_AUTO and #OPUS_BITRATE_MAX. |
|
||||
* The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much |
|
||||
* rate as it can, which is useful for controlling the rate by adjusting the |
|
||||
* output buffer size. |
|
||||
* @see OPUS_GET_BITRATE |
|
||||
* @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default |
|
||||
* is determined based on the number of |
|
||||
* channels and the input sampling rate. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's bitrate configuration.
|
|
||||
* @see OPUS_SET_BITRATE |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second. |
|
||||
* The default is determined based on the |
|
||||
* number of channels and the input |
|
||||
* sampling rate. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Enables or disables variable bitrate (VBR) in the encoder.
|
|
||||
* The configured bitrate may not be met exactly because frames must |
|
||||
* be an integer number of bytes in length. |
|
||||
* @see OPUS_GET_VBR |
|
||||
* @see OPUS_SET_VBR_CONSTRAINT |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can |
|
||||
* cause noticeable quality degradation.</dd> |
|
||||
* <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by |
|
||||
* #OPUS_SET_VBR_CONSTRAINT.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) |
|
||||
/** Determine if variable bitrate (VBR) is enabled in the encoder.
|
|
||||
* @see OPUS_SET_VBR |
|
||||
* @see OPUS_GET_VBR_CONSTRAINT |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Hard CBR.</dd> |
|
||||
* <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via |
|
||||
* #OPUS_GET_VBR_CONSTRAINT.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Enables or disables constrained VBR in the encoder.
|
|
||||
* This setting is ignored when the encoder is in CBR mode. |
|
||||
* @warning Only the MDCT mode of Opus currently heeds the constraint. |
|
||||
* Speech mode ignores it completely, hybrid mode may fail to obey it |
|
||||
* if the LPC layer uses more bitrate than the constraint would have |
|
||||
* permitted. |
|
||||
* @see OPUS_GET_VBR_CONSTRAINT |
|
||||
* @see OPUS_SET_VBR |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Unconstrained VBR.</dd> |
|
||||
* <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one |
|
||||
* frame of buffering delay assuming a transport with a |
|
||||
* serialization speed of the nominal bitrate.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x) |
|
||||
/** Determine if constrained VBR is enabled in the encoder.
|
|
||||
* @see OPUS_SET_VBR_CONSTRAINT |
|
||||
* @see OPUS_GET_VBR |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Unconstrained VBR.</dd> |
|
||||
* <dt>1</dt><dd>Constrained VBR (default).</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures mono/stereo forcing in the encoder.
|
|
||||
* This can force the encoder to produce packets encoded as either mono or |
|
||||
* stereo, regardless of the format of the input audio. This is useful when |
|
||||
* the caller knows that the input signal is currently a mono source embedded |
|
||||
* in a stereo stream. |
|
||||
* @see OPUS_GET_FORCE_CHANNELS |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
|
||||
* <dt>1</dt> <dd>Forced mono</dd> |
|
||||
* <dt>2</dt> <dd>Forced stereo</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's forced channel configuration.
|
|
||||
* @see OPUS_SET_FORCE_CHANNELS |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
|
||||
* <dt>1</dt> <dd>Forced mono</dd> |
|
||||
* <dt>2</dt> <dd>Forced stereo</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the maximum bandpass that the encoder will select automatically.
|
|
||||
* Applications should normally use this instead of #OPUS_SET_BANDWIDTH |
|
||||
* (leaving that set to the default, #OPUS_AUTO). This allows the |
|
||||
* application to set an upper bound based on the type of input it is |
|
||||
* providing, but still gives the encoder the freedom to reduce the bandpass |
|
||||
* when the bitrate becomes too low, for better overall quality. |
|
||||
* @see OPUS_GET_MAX_BANDWIDTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x) |
|
||||
|
|
||||
/** Gets the encoder's configured maximum allowed bandpass.
|
|
||||
* @see OPUS_SET_MAX_BANDWIDTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Sets the encoder's bandpass to a specific value.
|
|
||||
* This prevents the encoder from automatically selecting the bandpass based |
|
||||
* on the available bitrate. If an application knows the bandpass of the input |
|
||||
* audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH |
|
||||
* instead, which still gives the encoder the freedom to reduce the bandpass |
|
||||
* when the bitrate becomes too low, for better overall quality. |
|
||||
* @see OPUS_GET_BANDWIDTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) |
|
||||
|
|
||||
/** Configures the type of signal being encoded.
|
|
||||
* This is a hint which helps the encoder's mode selection. |
|
||||
* @see OPUS_GET_SIGNAL |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
|
||||
* <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured signal type.
|
|
||||
* @see OPUS_SET_SIGNAL |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
|
||||
* <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
|
|
||||
/** Configures the encoder's intended application.
|
|
||||
* The initial value is a mandatory argument to the encoder_create function. |
|
||||
* @see OPUS_GET_APPLICATION |
|
||||
* @param[in] x <tt>opus_int32</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured application.
|
|
||||
* @see OPUS_SET_APPLICATION |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the total samples of delay added by the entire codec.
|
|
||||
* This can be queried by the encoder and then the provided number of samples can be |
|
||||
* skipped on from the start of the decoder's output to provide time aligned input |
|
||||
* and output. From the perspective of a decoding application the real data begins this many |
|
||||
* samples late. |
|
||||
* |
|
||||
* The decoder contribution to this delay is identical for all decoders, but the |
|
||||
* encoder portion of the delay may vary from implementation to implementation, |
|
||||
* version to version, or even depend on the encoder's initial configuration. |
|
||||
* Applications needing delay compensation should call this CTL rather than |
|
||||
* hard-coding a value. |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of inband forward error correction (FEC).
|
|
||||
* @note This is only applicable to the LPC layer |
|
||||
* @see OPUS_GET_INBAND_FEC |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Disable inband FEC (default).</dd> |
|
||||
* <dt>1</dt><dd>Enable inband FEC.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) |
|
||||
/** Gets encoder's configured use of inband forward error correction.
|
|
||||
* @see OPUS_SET_INBAND_FEC |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Inband FEC disabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Inband FEC enabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's expected packet loss percentage.
|
|
||||
* Higher values trigger progressively more loss resistant behavior in the encoder |
|
||||
* at the expense of quality at a given bitrate in the absence of packet loss, but |
|
||||
* greater quality under loss. |
|
||||
* @see OPUS_GET_PACKET_LOSS_PERC |
|
||||
* @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured packet loss percentage.
|
|
||||
* @see OPUS_SET_PACKET_LOSS_PERC |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage |
|
||||
* in the range 0-100, inclusive (default: 0). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of discontinuous transmission (DTX).
|
|
||||
* @note This is only applicable to the LPC layer |
|
||||
* @see OPUS_GET_DTX |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Disable DTX (default).</dd> |
|
||||
* <dt>1</dt><dd>Enabled DTX.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) |
|
||||
/** Gets encoder's configured use of discontinuous transmission.
|
|
||||
* @see OPUS_SET_DTX |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>DTX disabled (default).</dd> |
|
||||
* <dt>1</dt><dd>DTX enabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) |
|
||||
/** Configures the depth of signal being encoded.
|
|
||||
* |
|
||||
* This is a hint which helps the encoder identify silence and near-silence. |
|
||||
* It represents the number of significant bits of linear intensity below |
|
||||
* which the signal contains ignorable quantization or other noise. |
|
||||
* |
|
||||
* For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting |
|
||||
* for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate |
|
||||
* for 16-bit linear pcm input with opus_encode_float(). |
|
||||
* |
|
||||
* When using opus_encode() instead of opus_encode_float(), or when libopus |
|
||||
* is compiled for fixed-point, the encoder uses the minimum of the value |
|
||||
* set here and the value 16. |
|
||||
* |
|
||||
* @see OPUS_GET_LSB_DEPTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24 |
|
||||
* (default: 24). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured signal depth.
|
|
||||
* @see OPUS_SET_LSB_DEPTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and |
|
||||
* 24 (default: 24). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of variable duration frames.
|
|
||||
* When variable duration is enabled, the encoder is free to use a shorter frame |
|
||||
* size than the one requested in the opus_encode*() call. |
|
||||
* It is then the user's responsibility |
|
||||
* to verify how much audio was encoded by checking the ToC byte of the encoded |
|
||||
* packet. The part of the audio that was not encoded needs to be resent to the |
|
||||
* encoder for the next call. Do not use this option unless you <b>really</b> |
|
||||
* know what you are doing. |
|
||||
* @see OPUS_GET_EXPERT_FRAME_DURATION |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured use of variable duration frames.
|
|
||||
* @see OPUS_SET_EXPERT_FRAME_DURATION |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** If set to 1, disables almost all use of prediction, making frames almost
|
|
||||
* completely independent. This reduces quality. |
|
||||
* @see OPUS_GET_PREDICTION_DISABLED |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Enable prediction (default).</dd> |
|
||||
* <dt>1</dt><dd>Disable prediction.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured prediction status.
|
|
||||
* @see OPUS_SET_PREDICTION_DISABLED |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Prediction enabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Prediction disabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_genericctls Generic CTLs
|
|
||||
* |
|
||||
* These macros are used with the \c opus_decoder_ctl and |
|
||||
* \c opus_encoder_ctl calls to generate a particular |
|
||||
* request. |
|
||||
* |
|
||||
* When called on an \c OpusDecoder they apply to that |
|
||||
* particular decoder instance. When called on an |
|
||||
* \c OpusEncoder they apply to the corresponding setting |
|
||||
* on that encoder instance, if present. |
|
||||
* |
|
||||
* Some usage examples: |
|
||||
* |
|
||||
* @code |
|
||||
* int ret; |
|
||||
* opus_int32 pitch; |
|
||||
* ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); |
|
||||
* if (ret == OPUS_OK) return ret; |
|
||||
* |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
|
||||
* opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); |
|
||||
* |
|
||||
* opus_int32 enc_bw, dec_bw; |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); |
|
||||
* opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); |
|
||||
* if (enc_bw != dec_bw) { |
|
||||
* printf("packet bandwidth mismatch!\n"); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Resets the codec state to be equivalent to a freshly initialized state.
|
|
||||
* This should be called when switching streams in order to prevent |
|
||||
* the back to back decoding from giving different results from |
|
||||
* one at a time decoding. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_RESET_STATE 4028 |
|
||||
|
|
||||
/** Gets the final state of the codec's entropy coder.
|
|
||||
* This is used for testing purposes, |
|
||||
* The encoder and decoder state should be identical after coding a payload |
|
||||
* (assuming no data corruption or software bugs) |
|
||||
* |
|
||||
* @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) |
|
||||
|
|
||||
/** Gets the encoder's configured bandpass or the decoder's last bandpass.
|
|
||||
* @see OPUS_SET_BANDWIDTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the sampling rate the encoder or decoder was initialized with.
|
|
||||
* This simply returns the <code>Fs</code> value passed to opus_encoder_init() |
|
||||
* or opus_decoder_init(). |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** If set to 1, disables the use of phase inversion for intensity stereo,
|
|
||||
* improving the quality of mono downmixes, but slightly reducing normal |
|
||||
* stereo quality. Disabling phase inversion in the decoder does not comply |
|
||||
* with RFC 6716, although it does not cause any interoperability issue and |
|
||||
* is expected to become part of the Opus standard once RFC 6716 is updated |
|
||||
* by draft-ietf-codec-opus-update. |
|
||||
* @see OPUS_GET_PHASE_INVERSION_DISABLED |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Enable phase inversion (default).</dd> |
|
||||
* <dt>1</dt><dd>Disable phase inversion.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured phase inversion status.
|
|
||||
* @see OPUS_SET_PHASE_INVERSION_DISABLED |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Stereo phase inversion enabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Stereo phase inversion disabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
|
||||
/** Gets the DTX state of the encoder.
|
|
||||
* Returns whether the last encoded frame was either a comfort noise update |
|
||||
* during DTX or not encoded because of DTX. |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>The encoder is not in DTX.</dd> |
|
||||
* <dt>1</dt><dd>The encoder is in DTX.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_IN_DTX(x) OPUS_GET_IN_DTX_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_decoderctls Decoder related CTLs
|
|
||||
* @see opus_genericctls, opus_encoderctls, opus_decoder |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Configures decoder gain adjustment.
|
|
||||
* Scales the decoded output by a factor specified in Q8 dB units. |
|
||||
* This has a maximum range of -32768 to 32767 inclusive, and returns |
|
||||
* OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. |
|
||||
* This setting survives decoder reset. |
|
||||
* |
|
||||
* gain = pow(10, x/(20.0*256)) |
|
||||
* |
|
||||
* @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN
|
|
||||
* |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the duration (in samples) of the last packet successfully decoded or concealed.
|
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the pitch of the last decoded frame, if available.
|
|
||||
* This can be used for any post-processing algorithm requiring the use of pitch, |
|
||||
* e.g. time stretching/shortening. If the last frame was not voiced, or if the |
|
||||
* pitch was not coded in the frame, then zero is returned. |
|
||||
* |
|
||||
* This CTL is only implemented for decoder instances. |
|
||||
* |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available) |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_libinfo Opus library information functions
|
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Converts an opus error code into a human readable string.
|
|
||||
* |
|
||||
* @param[in] error <tt>int</tt>: Error number |
|
||||
* @returns Error string |
|
||||
*/ |
|
||||
OPUS_EXPORT const char *opus_strerror(int error); |
|
||||
|
|
||||
/** Gets the libopus version string.
|
|
||||
* |
|
||||
* Applications may look for the substring "-fixed" in the version string to |
|
||||
* determine whether they have a fixed-point or floating-point build at |
|
||||
* runtime. |
|
||||
* |
|
||||
* @returns Version string |
|
||||
*/ |
|
||||
OPUS_EXPORT const char *opus_get_version_string(void); |
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_DEFINES_H */ |
|
||||
@ -1,660 +0,0 @@ |
|||||
/* Copyright (c) 2011 Xiph.Org Foundation
|
|
||||
Written by Jean-Marc Valin */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus_multistream.h |
|
||||
* @brief Opus reference implementation multistream API |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_MULTISTREAM_H |
|
||||
#define OPUS_MULTISTREAM_H |
|
||||
|
|
||||
#include "opus.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/** @cond OPUS_INTERNAL_DOC */ |
|
||||
|
|
||||
/** Macros to trigger compilation errors when the wrong types are provided to a
|
|
||||
* CTL. */ |
|
||||
/**@{*/ |
|
||||
#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr))) |
|
||||
#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr))) |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** These are the actual encoder and decoder CTL ID numbers.
|
|
||||
* They should not be used directly by applications. |
|
||||
* In general, SETs should be even and GETs should be odd.*/ |
|
||||
/**@{*/ |
|
||||
#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120 |
|
||||
#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122 |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @endcond */ |
|
||||
|
|
||||
/** @defgroup opus_multistream_ctls Multistream specific encoder and decoder CTLs
|
|
||||
* |
|
||||
* These are convenience macros that are specific to the |
|
||||
* opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl() |
|
||||
* interface. |
|
||||
* The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and |
|
||||
* @ref opus_decoderctls may be applied to a multistream encoder or decoder as |
|
||||
* well. |
|
||||
* In addition, you may retrieve the encoder or decoder state for an specific |
|
||||
* stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or |
|
||||
* #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually. |
|
||||
*/ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the encoder state for an individual stream of a multistream encoder.
|
|
||||
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose encoder you |
|
||||
* wish to retrieve. |
|
||||
* This must be non-negative and less than |
|
||||
* the <code>streams</code> parameter used |
|
||||
* to initialize the encoder. |
|
||||
* @param[out] y <tt>OpusEncoder**</tt>: Returns a pointer to the given |
|
||||
* encoder state. |
|
||||
* @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y) |
|
||||
|
|
||||
/** Gets the decoder state for an individual stream of a multistream decoder.
|
|
||||
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose decoder you |
|
||||
* wish to retrieve. |
|
||||
* This must be non-negative and less than |
|
||||
* the <code>streams</code> parameter used |
|
||||
* to initialize the decoder. |
|
||||
* @param[out] y <tt>OpusDecoder**</tt>: Returns a pointer to the given |
|
||||
* decoder state. |
|
||||
* @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_multistream Opus Multistream API
|
|
||||
* @{ |
|
||||
* |
|
||||
* The multistream API allows individual Opus streams to be combined into a |
|
||||
* single packet, enabling support for up to 255 channels. Unlike an |
|
||||
* elementary Opus stream, the encoder and decoder must negotiate the channel |
|
||||
* configuration before the decoder can successfully interpret the data in the |
|
||||
* packets produced by the encoder. Some basic information, such as packet |
|
||||
* duration, can be computed without any special negotiation. |
|
||||
* |
|
||||
* The format for multistream Opus packets is defined in |
|
||||
* <a href="https://tools.ietf.org/html/rfc7845">RFC 7845</a> |
|
||||
* and is based on the self-delimited Opus framing described in Appendix B of |
|
||||
* <a href="https://tools.ietf.org/html/rfc6716">RFC 6716</a>. |
|
||||
* Normal Opus packets are just a degenerate case of multistream Opus packets, |
|
||||
* and can be encoded or decoded with the multistream API by setting |
|
||||
* <code>streams</code> to <code>1</code> when initializing the encoder or |
|
||||
* decoder. |
|
||||
* |
|
||||
* Multistream Opus streams can contain up to 255 elementary Opus streams. |
|
||||
* These may be either "uncoupled" or "coupled", indicating that the decoder |
|
||||
* is configured to decode them to either 1 or 2 channels, respectively. |
|
||||
* The streams are ordered so that all coupled streams appear at the |
|
||||
* beginning. |
|
||||
* |
|
||||
* A <code>mapping</code> table defines which decoded channel <code>i</code> |
|
||||
* should be used for each input/output (I/O) channel <code>j</code>. This table is |
|
||||
* typically provided as an unsigned char array. |
|
||||
* Let <code>i = mapping[j]</code> be the index for I/O channel <code>j</code>. |
|
||||
* If <code>i < 2*coupled_streams</code>, then I/O channel <code>j</code> is |
|
||||
* encoded as the left channel of stream <code>(i/2)</code> if <code>i</code> |
|
||||
* is even, or as the right channel of stream <code>(i/2)</code> if |
|
||||
* <code>i</code> is odd. Otherwise, I/O channel <code>j</code> is encoded as |
|
||||
* mono in stream <code>(i - coupled_streams)</code>, unless it has the special |
|
||||
* value 255, in which case it is omitted from the encoding entirely (the |
|
||||
* decoder will reproduce it as silence). Each value <code>i</code> must either |
|
||||
* be the special value 255 or be less than <code>streams + coupled_streams</code>. |
|
||||
* |
|
||||
* The output channels specified by the encoder |
|
||||
* should use the |
|
||||
* <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis |
|
||||
* channel ordering</a>. A decoder may wish to apply an additional permutation |
|
||||
* to the mapping the encoder used to achieve a different output channel |
|
||||
* order (e.g. for outputing in WAV order). |
|
||||
* |
|
||||
* Each multistream packet contains an Opus packet for each stream, and all of |
|
||||
* the Opus packets in a single multistream packet must have the same |
|
||||
* duration. Therefore the duration of a multistream packet can be extracted |
|
||||
* from the TOC sequence of the first stream, which is located at the |
|
||||
* beginning of the packet, just like an elementary Opus stream: |
|
||||
* |
|
||||
* @code |
|
||||
* int nb_samples; |
|
||||
* int nb_frames; |
|
||||
* nb_frames = opus_packet_get_nb_frames(data, len); |
|
||||
* if (nb_frames < 1) |
|
||||
* return nb_frames; |
|
||||
* nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames; |
|
||||
* @endcode |
|
||||
* |
|
||||
* The general encoding and decoding process proceeds exactly the same as in |
|
||||
* the normal @ref opus_encoder and @ref opus_decoder APIs. |
|
||||
* See their documentation for an overview of how to use the corresponding |
|
||||
* multistream functions. |
|
||||
*/ |
|
||||
|
|
||||
/** Opus multistream encoder state.
|
|
||||
* This contains the complete state of a multistream Opus encoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_multistream_encoder_create |
|
||||
* @see opus_multistream_encoder_init |
|
||||
*/ |
|
||||
typedef struct OpusMSEncoder OpusMSEncoder; |
|
||||
|
|
||||
/** Opus multistream decoder state.
|
|
||||
* This contains the complete state of a multistream Opus decoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_multistream_decoder_create |
|
||||
* @see opus_multistream_decoder_init |
|
||||
*/ |
|
||||
typedef struct OpusMSDecoder OpusMSDecoder; |
|
||||
|
|
||||
/**\name Multistream encoder functions */ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the size of an OpusMSEncoder structure.
|
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @returns The size in bytes on success, or a negative error code |
|
||||
* (see @ref opus_errorcodes) on error. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size( |
|
||||
int streams, |
|
||||
int coupled_streams |
|
||||
); |
|
||||
|
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size( |
|
||||
int channels, |
|
||||
int mapping_family |
|
||||
); |
|
||||
|
|
||||
|
|
||||
/** Allocates and initializes a multistream encoder state.
|
|
||||
* Call opus_multistream_encoder_destroy() to release |
|
||||
* this object when finished. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels in the input signal. |
|
||||
* This must be at most 255. |
|
||||
* It may be greater than the number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than the number of channels. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than the number of input channels. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* encoded channels to input channels, as described in |
|
||||
* @ref opus_multistream. As an extra constraint, the |
|
||||
* multistream encoder does not allow encoding coupled |
|
||||
* streams for which one channel is unused since this |
|
||||
* is never a good idea. |
|
||||
* @param application <tt>int</tt>: The target encoder application. |
|
||||
* This must be one of the following: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
|
||||
* code (see @ref opus_errorcodes) on |
|
||||
* failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int application, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_surround_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int mapping_family, |
|
||||
int *streams, |
|
||||
int *coupled_streams, |
|
||||
unsigned char *mapping, |
|
||||
int application, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
/** Initialize a previously allocated multistream encoder state.
|
|
||||
* The memory pointed to by \a st must be at least the size returned by |
|
||||
* opus_multistream_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of |
|
||||
* malloc. |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @see opus_multistream_encoder_create |
|
||||
* @see opus_multistream_encoder_get_size |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels in the input signal. |
|
||||
* This must be at most 255. |
|
||||
* It may be greater than the number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than the number of channels. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than the number of input channels. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* encoded channels to input channels, as described in |
|
||||
* @ref opus_multistream. As an extra constraint, the |
|
||||
* multistream encoder does not allow encoding coupled |
|
||||
* streams for which one channel is unused since this |
|
||||
* is never a good idea. |
|
||||
* @param application <tt>int</tt>: The target encoder application. |
|
||||
* This must be one of the following: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
|
||||
* on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_encoder_init( |
|
||||
OpusMSEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
OPUS_EXPORT int opus_multistream_surround_encoder_init( |
|
||||
OpusMSEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int mapping_family, |
|
||||
int *streams, |
|
||||
int *coupled_streams, |
|
||||
unsigned char *mapping, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6) OPUS_ARG_NONNULL(7); |
|
||||
|
|
||||
/** Encodes a multistream Opus frame.
|
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved |
|
||||
* samples. |
|
||||
* This must contain |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: Number of samples per channel in the input |
|
||||
* signal. |
|
||||
* This must be an Opus frame size for the |
|
||||
* encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted values |
|
||||
* are 120, 240, 480, 960, 1920, and 2880. |
|
||||
* Passing in a duration of less than 10 ms |
|
||||
* (480 samples at 48 kHz) will prevent the |
|
||||
* encoder from using the LPC or hybrid modes. |
|
||||
* @param[out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode( |
|
||||
OpusMSEncoder *st, |
|
||||
const opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Encodes a multistream Opus frame from floating point input.
|
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param[in] pcm <tt>const float*</tt>: The input signal as interleaved |
|
||||
* samples with a normal range of |
|
||||
* +/-1.0. |
|
||||
* Samples with a range beyond +/-1.0 |
|
||||
* are supported but will be clipped by |
|
||||
* decoders using the integer API and |
|
||||
* should only be used if it is known |
|
||||
* that the far end supports extended |
|
||||
* dynamic range. |
|
||||
* This must contain |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: Number of samples per channel in the input |
|
||||
* signal. |
|
||||
* This must be an Opus frame size for the |
|
||||
* encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted values |
|
||||
* are 120, 240, 480, 960, 1920, and 2880. |
|
||||
* Passing in a duration of less than 10 ms |
|
||||
* (480 samples at 48 kHz) will prevent the |
|
||||
* encoder from using the LPC or hybrid modes. |
|
||||
* @param[out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float( |
|
||||
OpusMSEncoder *st, |
|
||||
const float *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Frees an <code>OpusMSEncoder</code> allocated by
|
|
||||
* opus_multistream_encoder_create(). |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st); |
|
||||
|
|
||||
/** Perform a CTL function on a multistream Opus encoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated by a |
|
||||
* convenience macro. |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls, |
|
||||
* @ref opus_encoderctls, or @ref opus_multistream_ctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_encoderctls |
|
||||
* @see opus_multistream_ctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/**\name Multistream decoder functions */ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the size of an <code>OpusMSDecoder</code> structure.
|
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @returns The size in bytes on success, or a negative error code |
|
||||
* (see @ref opus_errorcodes) on error. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size( |
|
||||
int streams, |
|
||||
int coupled_streams |
|
||||
); |
|
||||
|
|
||||
/** Allocates and initializes a multistream decoder state.
|
|
||||
* Call opus_multistream_decoder_destroy() to release |
|
||||
* this object when finished. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels to output. |
|
||||
* This must be at most 255. |
|
||||
* It may be different from the number of coded |
|
||||
* channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* coded channels to output channels, as described in |
|
||||
* @ref opus_multistream. |
|
||||
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
|
||||
* code (see @ref opus_errorcodes) on |
|
||||
* failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
/** Intialize a previously allocated decoder state object.
|
|
||||
* The memory pointed to by \a st must be at least the size returned by |
|
||||
* opus_multistream_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of |
|
||||
* malloc. |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @see opus_multistream_decoder_create |
|
||||
* @see opus_multistream_deocder_get_size |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels to output. |
|
||||
* This must be at most 255. |
|
||||
* It may be different from the number of coded |
|
||||
* channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* coded channels to output channels, as described in |
|
||||
* @ref opus_multistream. |
|
||||
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
|
||||
* on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_decoder_init( |
|
||||
OpusMSDecoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
/** Decode a multistream Opus packet.
|
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: Input payload. |
|
||||
* Use a <code>NULL</code> |
|
||||
* pointer to indicate packet |
|
||||
* loss. |
|
||||
* @param len <tt>opus_int32</tt>: Number of bytes in payload. |
|
||||
* @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
|
||||
* samples. |
|
||||
* This must contain room for |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: The number of samples per channel of |
|
||||
* available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration |
|
||||
* (120 ms; 5760 for 48kHz), this function will not be capable |
|
||||
* of decoding some packets. In the case of PLC (data==NULL) |
|
||||
* or FEC (decode_fec=1), then frame_size needs to be exactly |
|
||||
* the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the |
|
||||
* next incoming packet. For the PLC and FEC cases, frame_size |
|
||||
* <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
|
||||
* forward error correction data be decoded. |
|
||||
* If no such data is available, the frame is |
|
||||
* decoded as if it were lost. |
|
||||
* @returns Number of samples decoded on success or a negative error code |
|
||||
* (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode( |
|
||||
OpusMSDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Decode a multistream Opus packet with floating point output.
|
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: Input payload. |
|
||||
* Use a <code>NULL</code> |
|
||||
* pointer to indicate packet |
|
||||
* loss. |
|
||||
* @param len <tt>opus_int32</tt>: Number of bytes in payload. |
|
||||
* @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
|
||||
* samples. |
|
||||
* This must contain room for |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: The number of samples per channel of |
|
||||
* available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration |
|
||||
* (120 ms; 5760 for 48kHz), this function will not be capable |
|
||||
* of decoding some packets. In the case of PLC (data==NULL) |
|
||||
* or FEC (decode_fec=1), then frame_size needs to be exactly |
|
||||
* the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the |
|
||||
* next incoming packet. For the PLC and FEC cases, frame_size |
|
||||
* <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
|
||||
* forward error correction data be decoded. |
|
||||
* If no such data is available, the frame is |
|
||||
* decoded as if it were lost. |
|
||||
* @returns Number of samples decoded on success or a negative error code |
|
||||
* (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float( |
|
||||
OpusMSDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
float *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Perform a CTL function on a multistream Opus decoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated by a |
|
||||
* convenience macro. |
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls, |
|
||||
* @ref opus_decoderctls, or @ref opus_multistream_ctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_decoderctls |
|
||||
* @see opus_multistream_ctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Frees an <code>OpusMSDecoder</code> allocated by
|
|
||||
* opus_multistream_decoder_create(). |
|
||||
* @param st <tt>OpusMSDecoder</tt>: Multistream decoder state to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_MULTISTREAM_H */ |
|
||||
@ -1,36 +0,0 @@ |
|||||
//
|
|
||||
// opus_swift.h
|
|
||||
// opus-swift
|
|
||||
//
|
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology
|
|
||||
//
|
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||
// in the Software without restriction, including without limitation the rights
|
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||
// furnished to do so, subject to the following conditions:
|
|
||||
//
|
|
||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||
// copies or substantial portions of the Software.
|
|
||||
//
|
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||
// SOFTWARE.
|
|
||||
//
|
|
||||
|
|
||||
#include <TargetConditionals.h> |
|
||||
|
|
||||
#if TARGET_OS_IPHONE |
|
||||
@import UIKit; |
|
||||
#else |
|
||||
@import AppKit; |
|
||||
#endif |
|
||||
|
|
||||
#include "opus.h" |
|
||||
#include "opus_multistream.h" |
|
||||
|
|
||||
@ -1,166 +0,0 @@ |
|||||
/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */ |
|
||||
/* Modified by Jean-Marc Valin */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
/* opus_types.h based on ogg_types.h from libogg */ |
|
||||
|
|
||||
/**
|
|
||||
@file opus_types.h |
|
||||
@brief Opus reference implementation types |
|
||||
*/ |
|
||||
#ifndef OPUS_TYPES_H |
|
||||
#define OPUS_TYPES_H |
|
||||
|
|
||||
#define opus_int int /* used for counters etc; at least 16 bits */ |
|
||||
#define opus_int64 long long |
|
||||
#define opus_int8 signed char |
|
||||
|
|
||||
#define opus_uint unsigned int /* used for counters etc; at least 16 bits */ |
|
||||
#define opus_uint64 unsigned long long |
|
||||
#define opus_uint8 unsigned char |
|
||||
|
|
||||
/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ |
|
||||
#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) |
|
||||
#include <stdint.h> |
|
||||
# undef opus_int64 |
|
||||
# undef opus_int8 |
|
||||
# undef opus_uint64 |
|
||||
# undef opus_uint8 |
|
||||
typedef int8_t opus_int8; |
|
||||
typedef uint8_t opus_uint8; |
|
||||
typedef int16_t opus_int16; |
|
||||
typedef uint16_t opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef uint32_t opus_uint32; |
|
||||
typedef int64_t opus_int64; |
|
||||
typedef uint64_t opus_uint64; |
|
||||
#elif defined(_WIN32) |
|
||||
|
|
||||
# if defined(__CYGWIN__) |
|
||||
# include <_G_config.h> |
|
||||
typedef _G_int32_t opus_int32; |
|
||||
typedef _G_uint32_t opus_uint32; |
|
||||
typedef _G_int16 opus_int16; |
|
||||
typedef _G_uint16 opus_uint16; |
|
||||
# elif defined(__MINGW32__) |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
# elif defined(__MWERKS__) |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
# else |
|
||||
/* MSVC/Borland */ |
|
||||
typedef __int32 opus_int32; |
|
||||
typedef unsigned __int32 opus_uint32; |
|
||||
typedef __int16 opus_int16; |
|
||||
typedef unsigned __int16 opus_uint16; |
|
||||
# endif |
|
||||
|
|
||||
#elif defined(__MACOS__) |
|
||||
|
|
||||
# include <sys/types.h> |
|
||||
typedef SInt16 opus_int16; |
|
||||
typedef UInt16 opus_uint16; |
|
||||
typedef SInt32 opus_int32; |
|
||||
typedef UInt32 opus_uint32; |
|
||||
|
|
||||
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ |
|
||||
|
|
||||
# include <sys/types.h> |
|
||||
typedef int16_t opus_int16; |
|
||||
typedef u_int16_t opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef u_int32_t opus_uint32; |
|
||||
|
|
||||
#elif defined(__BEOS__) |
|
||||
|
|
||||
/* Be */ |
|
||||
# include <inttypes.h> |
|
||||
typedef int16 opus_int16; |
|
||||
typedef u_int16 opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef u_int32_t opus_uint32; |
|
||||
|
|
||||
#elif defined (__EMX__) |
|
||||
|
|
||||
/* OS/2 GCC */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined (DJGPP) |
|
||||
|
|
||||
/* DJGPP */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined(R5900) |
|
||||
|
|
||||
/* PS2 EE */ |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned opus_uint32; |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
|
|
||||
#elif defined(__SYMBIAN32__) |
|
||||
|
|
||||
/* Symbian GCC */ |
|
||||
typedef signed short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef signed int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) |
|
||||
|
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef long opus_int32; |
|
||||
typedef unsigned long opus_uint32; |
|
||||
|
|
||||
#elif defined(CONFIG_TI_C6X) |
|
||||
|
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#else |
|
||||
|
|
||||
/* Give up, take a reasonable guess */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_TYPES_H */ |
|
||||
Binary file not shown.
@ -1,29 +0,0 @@ |
|||||
// |
|
||||
// module.modulemap |
|
||||
// opus-swift |
|
||||
// |
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
// |
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
// of this software and associated documentation files (the "Software"), to deal |
|
||||
// in the Software without restriction, including without limitation the rights |
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
// copies of the Software, and to permit persons to whom the Software is |
|
||||
// furnished to do so, subject to the following conditions: |
|
||||
// |
|
||||
// The above copyright notice and this permission notice shall be included in all |
|
||||
// copies or substantial portions of the Software. |
|
||||
// |
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||
// SOFTWARE. |
|
||||
// |
|
||||
|
|
||||
framework module YbridOpus { |
|
||||
umbrella header "opus_swift.h" |
|
||||
export * |
|
||||
} |
|
||||
Binary file not shown.
@ -1,207 +0,0 @@ |
|||||
<?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>files</key> |
|
||||
<dict> |
|
||||
<key>Config.xcconfig</key> |
|
||||
<data> |
|
||||
+CifWGfGG+eJ+6RQiR2J6Z9++KM= |
|
||||
</data> |
|
||||
<key>Headers/opus.h</key> |
|
||||
<data> |
|
||||
9iqWh6KOQxloZd6AR4Nln9WTpGM= |
|
||||
</data> |
|
||||
<key>Headers/opus_defines.h</key> |
|
||||
<data> |
|
||||
ZIxZY8da41baCR/GF2/AFpe6cck= |
|
||||
</data> |
|
||||
<key>Headers/opus_multistream.h</key> |
|
||||
<data> |
|
||||
BckYtz94plsXQZ9RBWuV/1kcmxw= |
|
||||
</data> |
|
||||
<key>Headers/opus_swift.h</key> |
|
||||
<data> |
|
||||
LzT5PUj/rbYaW1AxYg5wVXuXbDA= |
|
||||
</data> |
|
||||
<key>Headers/opus_types.h</key> |
|
||||
<data> |
|
||||
4eY+K/HQ77ZaFO9EKPVfVs7L2jM= |
|
||||
</data> |
|
||||
<key>Info.plist</key> |
|
||||
<data> |
|
||||
VDcGbi+CICjBJ9cahFRuboF4eQ8= |
|
||||
</data> |
|
||||
<key>Modules/module.modulemap</key> |
|
||||
<data> |
|
||||
fEkglRKWfXEJ5P20WiaR5jn2i6Y= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>files2</key> |
|
||||
<dict> |
|
||||
<key>Config.xcconfig</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
+CifWGfGG+eJ+6RQiR2J6Z9++KM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
yWuzbLu2XVuQ/KyJjefCQA6yUIG/ledJEQXfvayiZ78= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
9iqWh6KOQxloZd6AR4Nln9WTpGM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
jPzA/v85IbzDiXG+tLPzcFiknByl2mtZ+0r2OOIfjuY= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_defines.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
ZIxZY8da41baCR/GF2/AFpe6cck= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
9DvrxB739706a104pEEDAbTM24VK2EL+mF6TUjgCRAs= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_multistream.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
BckYtz94plsXQZ9RBWuV/1kcmxw= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
G/OMOd/e727v31BLWFvk1IgsAeQcWojBJJlSsQpQDvg= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_swift.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
LzT5PUj/rbYaW1AxYg5wVXuXbDA= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
tU2j9To8QDSbhu8Vz/Lv1Y6uYjEGHp0e5a6RsnGglFM= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_types.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
4eY+K/HQ77ZaFO9EKPVfVs7L2jM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
GcswHqHu28vbtQSTY94GGJO/EcIOUFple2nOb/pbEfo= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Modules/module.modulemap</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
fEkglRKWfXEJ5P20WiaR5jn2i6Y= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
spkcimiabUAXiltxFizEevGEO4anKye9lDyB981i/XU= |
|
||||
</data> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
<key>rules</key> |
|
||||
<dict> |
|
||||
<key>^.*</key> |
|
||||
<true/> |
|
||||
<key>^.*\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>optional</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1000</real> |
|
||||
</dict> |
|
||||
<key>^.*\.lproj/locversion.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1100</real> |
|
||||
</dict> |
|
||||
<key>^Base\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>1010</real> |
|
||||
</dict> |
|
||||
<key>^version.plist$</key> |
|
||||
<true/> |
|
||||
</dict> |
|
||||
<key>rules2</key> |
|
||||
<dict> |
|
||||
<key>.*\.dSYM($|/)</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>11</real> |
|
||||
</dict> |
|
||||
<key>^(.*/)?\.DS_Store$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>2000</real> |
|
||||
</dict> |
|
||||
<key>^.*</key> |
|
||||
<true/> |
|
||||
<key>^.*\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>optional</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1000</real> |
|
||||
</dict> |
|
||||
<key>^.*\.lproj/locversion.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1100</real> |
|
||||
</dict> |
|
||||
<key>^Base\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>1010</real> |
|
||||
</dict> |
|
||||
<key>^Info\.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^PkgInfo$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^embedded\.provisionprofile$</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^version\.plist$</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
</plist> |
|
||||
@ -1 +0,0 @@ |
|||||
Versions/Current/Headers |
|
||||
@ -1 +0,0 @@ |
|||||
Versions/Current/Modules |
|
||||
@ -1 +0,0 @@ |
|||||
Versions/Current/Resources |
|
||||
@ -1,981 +0,0 @@ |
|||||
/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
|
|
||||
Written by Jean-Marc Valin and Koen Vos */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus.h |
|
||||
* @brief Opus reference implementation API |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_H |
|
||||
#define OPUS_H |
|
||||
|
|
||||
#include "opus_types.h" |
|
||||
#include "opus_defines.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/**
|
|
||||
* @mainpage Opus |
|
||||
* |
|
||||
* The Opus codec is designed for interactive speech and audio transmission over the Internet. |
|
||||
* It is designed by the IETF Codec Working Group and incorporates technology from |
|
||||
* Skype's SILK codec and Xiph.Org's CELT codec. |
|
||||
* |
|
||||
* The Opus codec is designed to handle a wide range of interactive audio applications, |
|
||||
* including Voice over IP, videoconferencing, in-game chat, and even remote live music |
|
||||
* performances. It can scale from low bit-rate narrowband speech to very high quality |
|
||||
* stereo music. Its main features are: |
|
||||
|
|
||||
* @li Sampling rates from 8 to 48 kHz |
|
||||
* @li Bit-rates from 6 kb/s to 510 kb/s |
|
||||
* @li Support for both constant bit-rate (CBR) and variable bit-rate (VBR) |
|
||||
* @li Audio bandwidth from narrowband to full-band |
|
||||
* @li Support for speech and music |
|
||||
* @li Support for mono and stereo |
|
||||
* @li Support for multichannel (up to 255 channels) |
|
||||
* @li Frame sizes from 2.5 ms to 60 ms |
|
||||
* @li Good loss robustness and packet loss concealment (PLC) |
|
||||
* @li Floating point and fixed-point implementation |
|
||||
* |
|
||||
* Documentation sections: |
|
||||
* @li @ref opus_encoder |
|
||||
* @li @ref opus_decoder |
|
||||
* @li @ref opus_repacketizer |
|
||||
* @li @ref opus_multistream |
|
||||
* @li @ref opus_libinfo |
|
||||
* @li @ref opus_custom |
|
||||
*/ |
|
||||
|
|
||||
/** @defgroup opus_encoder Opus Encoder
|
|
||||
* @{ |
|
||||
* |
|
||||
* @brief This page describes the process and functions used to encode Opus. |
|
||||
* |
|
||||
* Since Opus is a stateful codec, the encoding process starts with creating an encoder |
|
||||
* state. This can be done with: |
|
||||
* |
|
||||
* @code |
|
||||
* int error; |
|
||||
* OpusEncoder *enc; |
|
||||
* enc = opus_encoder_create(Fs, channels, application, &error); |
|
||||
* @endcode |
|
||||
* |
|
||||
* From this point, @c enc can be used for encoding an audio stream. An encoder state |
|
||||
* @b must @b not be used for more than one stream at the same time. Similarly, the encoder |
|
||||
* state @b must @b not be re-initialized for each frame. |
|
||||
* |
|
||||
* While opus_encoder_create() allocates memory for the state, it's also possible |
|
||||
* to initialize pre-allocated memory: |
|
||||
* |
|
||||
* @code |
|
||||
* int size; |
|
||||
* int error; |
|
||||
* OpusEncoder *enc; |
|
||||
* size = opus_encoder_get_size(channels); |
|
||||
* enc = malloc(size); |
|
||||
* error = opus_encoder_init(enc, Fs, channels, application); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where opus_encoder_get_size() returns the required size for the encoder state. Note that |
|
||||
* future versions of this code may change the size, so no assuptions should be made about it. |
|
||||
* |
|
||||
* The encoder state is always continuous in memory and only a shallow copy is sufficient |
|
||||
* to copy it (e.g. memcpy()) |
|
||||
* |
|
||||
* It is possible to change some of the encoder's settings using the opus_encoder_ctl() |
|
||||
* interface. All these settings already default to the recommended value, so they should |
|
||||
* only be changed when necessary. The most common settings one may want to change are: |
|
||||
* |
|
||||
* @code |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_BITRATE(bitrate)); |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_COMPLEXITY(complexity)); |
|
||||
* opus_encoder_ctl(enc, OPUS_SET_SIGNAL(signal_type)); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where |
|
||||
* |
|
||||
* @arg bitrate is in bits per second (b/s) |
|
||||
* @arg complexity is a value from 1 to 10, where 1 is the lowest complexity and 10 is the highest |
|
||||
* @arg signal_type is either OPUS_AUTO (default), OPUS_SIGNAL_VOICE, or OPUS_SIGNAL_MUSIC |
|
||||
* |
|
||||
* See @ref opus_encoderctls and @ref opus_genericctls for a complete list of parameters that can be set or queried. Most parameters can be set or changed at any time during a stream. |
|
||||
* |
|
||||
* To encode a frame, opus_encode() or opus_encode_float() must be called with exactly one frame (2.5, 5, 10, 20, 40 or 60 ms) of audio data: |
|
||||
* @code |
|
||||
* len = opus_encode(enc, audio_frame, frame_size, packet, max_packet); |
|
||||
* @endcode |
|
||||
* |
|
||||
* where |
|
||||
* <ul> |
|
||||
* <li>audio_frame is the audio data in opus_int16 (or float for opus_encode_float())</li> |
|
||||
* <li>frame_size is the duration of the frame in samples (per channel)</li> |
|
||||
* <li>packet is the byte array to which the compressed data is written</li> |
|
||||
* <li>max_packet is the maximum number of bytes that can be written in the packet (4000 bytes is recommended). |
|
||||
* Do not use max_packet to control VBR target bitrate, instead use the #OPUS_SET_BITRATE CTL.</li> |
|
||||
* </ul> |
|
||||
* |
|
||||
* opus_encode() and opus_encode_float() return the number of bytes actually written to the packet. |
|
||||
* The return value <b>can be negative</b>, which indicates that an error has occurred. If the return value |
|
||||
* is 2 bytes or less, then the packet does not need to be transmitted (DTX). |
|
||||
* |
|
||||
* Once the encoder state if no longer needed, it can be destroyed with |
|
||||
* |
|
||||
* @code |
|
||||
* opus_encoder_destroy(enc); |
|
||||
* @endcode |
|
||||
* |
|
||||
* If the encoder was created with opus_encoder_init() rather than opus_encoder_create(), |
|
||||
* then no action is required aside from potentially freeing the memory that was manually |
|
||||
* allocated for it (calling free(enc) for the example above) |
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
/** Opus encoder state.
|
|
||||
* This contains the complete state of an Opus encoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_encoder_create,opus_encoder_init |
|
||||
*/ |
|
||||
typedef struct OpusEncoder OpusEncoder; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusEncoder</code> structure.
|
|
||||
* @param[in] channels <tt>int</tt>: Number of channels. |
|
||||
* This must be 1 or 2. |
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels); |
|
||||
|
|
||||
/**
|
|
||||
*/ |
|
||||
|
|
||||
/** Allocates and initializes an encoder state.
|
|
||||
* There are three coding modes: |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_VOIP gives best quality at a given bitrate for voice |
|
||||
* signals. It enhances the input signal by high-pass filtering and |
|
||||
* emphasizing formants and harmonics. Optionally it includes in-band |
|
||||
* forward error correction to protect against packet loss. Use this |
|
||||
* mode for typical VoIP applications. Because of the enhancement, |
|
||||
* even at high bitrates the output may sound different from the input. |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_AUDIO gives best quality at a given bitrate for most |
|
||||
* non-voice signals like music. Use this mode for music and mixed |
|
||||
* (music/voice) content, broadcast, and applications requiring less |
|
||||
* than 15 ms of coding delay. |
|
||||
* |
|
||||
* @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY configures low-delay mode that |
|
||||
* disables the speech-optimized mode in exchange for slightly reduced delay. |
|
||||
* This mode can only be set on an newly initialized or freshly reset encoder |
|
||||
* because it changes the codec delay. |
|
||||
* |
|
||||
* This is useful when the caller knows that the speech-optimized modes will not be needed (use with caution). |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
|
||||
* @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
|
||||
* @param [out] error <tt>int*</tt>: @ref opus_errorcodes |
|
||||
* @note Regardless of the sampling rate and number channels selected, the Opus encoder |
|
||||
* can switch to a lower audio bandwidth or number of channels if the bitrate |
|
||||
* selected is too low. This also means that it is safe to always use 48 kHz stereo input |
|
||||
* and let the encoder optimize the encoding. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int application, |
|
||||
int *error |
|
||||
); |
|
||||
|
|
||||
/** Initializes a previously allocated encoder state
|
|
||||
* The memory pointed to by st must be at least the size returned by opus_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of malloc. |
|
||||
* @see opus_encoder_create(),opus_encoder_get_size() |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate of input signal (Hz) |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal |
|
||||
* @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY) |
|
||||
* @retval #OPUS_OK Success or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_encoder_init( |
|
||||
OpusEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Encodes an Opus frame.
|
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] pcm <tt>opus_int16*</tt>: Input signal (interleaved if 2 channels). length is frame_size*channels*sizeof(opus_int16) |
|
||||
* @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
|
||||
* input signal. |
|
||||
* This must be an Opus frame size for |
|
||||
* the encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted |
|
||||
* values are 120, 240, 480, 960, 1920, |
|
||||
* and 2880. |
|
||||
* Passing in a duration of less than |
|
||||
* 10 ms (480 samples at 48 kHz) will |
|
||||
* prevent the encoder from using the LPC |
|
||||
* or hybrid modes. |
|
||||
* @param [out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode( |
|
||||
OpusEncoder *st, |
|
||||
const opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Encodes an Opus frame from floating point input.
|
|
||||
* @param [in] st <tt>OpusEncoder*</tt>: Encoder state |
|
||||
* @param [in] pcm <tt>float*</tt>: Input in float format (interleaved if 2 channels), with a normal range of +/-1.0. |
|
||||
* Samples with a range beyond +/-1.0 are supported but will |
|
||||
* be clipped by decoders using the integer API and should |
|
||||
* only be used if it is known that the far end supports |
|
||||
* extended dynamic range. |
|
||||
* length is frame_size*channels*sizeof(float) |
|
||||
* @param [in] frame_size <tt>int</tt>: Number of samples per channel in the |
|
||||
* input signal. |
|
||||
* This must be an Opus frame size for |
|
||||
* the encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted |
|
||||
* values are 120, 240, 480, 960, 1920, |
|
||||
* and 2880. |
|
||||
* Passing in a duration of less than |
|
||||
* 10 ms (480 samples at 48 kHz) will |
|
||||
* prevent the encoder from using the LPC |
|
||||
* or hybrid modes. |
|
||||
* @param [out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_encode_float( |
|
||||
OpusEncoder *st, |
|
||||
const float *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Frees an <code>OpusEncoder</code> allocated by opus_encoder_create().
|
|
||||
* @param[in] st <tt>OpusEncoder*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_encoder_destroy(OpusEncoder *st); |
|
||||
|
|
||||
/** Perform a CTL function on an Opus encoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated |
|
||||
* by a convenience macro. |
|
||||
* @param st <tt>OpusEncoder*</tt>: Encoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls or |
|
||||
* @ref opus_encoderctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_encoderctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_encoder_ctl(OpusEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_decoder Opus Decoder
|
|
||||
* @{ |
|
||||
* |
|
||||
* @brief This page describes the process and functions used to decode Opus. |
|
||||
* |
|
||||
* The decoding process also starts with creating a decoder |
|
||||
* state. This can be done with: |
|
||||
* @code |
|
||||
* int error; |
|
||||
* OpusDecoder *dec; |
|
||||
* dec = opus_decoder_create(Fs, channels, &error); |
|
||||
* @endcode |
|
||||
* where |
|
||||
* @li Fs is the sampling rate and must be 8000, 12000, 16000, 24000, or 48000 |
|
||||
* @li channels is the number of channels (1 or 2) |
|
||||
* @li error will hold the error code in case of failure (or #OPUS_OK on success) |
|
||||
* @li the return value is a newly created decoder state to be used for decoding |
|
||||
* |
|
||||
* While opus_decoder_create() allocates memory for the state, it's also possible |
|
||||
* to initialize pre-allocated memory: |
|
||||
* @code |
|
||||
* int size; |
|
||||
* int error; |
|
||||
* OpusDecoder *dec; |
|
||||
* size = opus_decoder_get_size(channels); |
|
||||
* dec = malloc(size); |
|
||||
* error = opus_decoder_init(dec, Fs, channels); |
|
||||
* @endcode |
|
||||
* where opus_decoder_get_size() returns the required size for the decoder state. Note that |
|
||||
* future versions of this code may change the size, so no assuptions should be made about it. |
|
||||
* |
|
||||
* The decoder state is always continuous in memory and only a shallow copy is sufficient |
|
||||
* to copy it (e.g. memcpy()) |
|
||||
* |
|
||||
* To decode a frame, opus_decode() or opus_decode_float() must be called with a packet of compressed audio data: |
|
||||
* @code |
|
||||
* frame_size = opus_decode(dec, packet, len, decoded, max_size, 0); |
|
||||
* @endcode |
|
||||
* where |
|
||||
* |
|
||||
* @li packet is the byte array containing the compressed data |
|
||||
* @li len is the exact number of bytes contained in the packet |
|
||||
* @li decoded is the decoded audio data in opus_int16 (or float for opus_decode_float()) |
|
||||
* @li max_size is the max duration of the frame in samples (per channel) that can fit into the decoded_frame array |
|
||||
* |
|
||||
* opus_decode() and opus_decode_float() return the number of samples (per channel) decoded from the packet. |
|
||||
* If that value is negative, then an error has occurred. This can occur if the packet is corrupted or if the audio |
|
||||
* buffer is too small to hold the decoded audio. |
|
||||
* |
|
||||
* Opus is a stateful codec with overlapping blocks and as a result Opus |
|
||||
* packets are not coded independently of each other. Packets must be |
|
||||
* passed into the decoder serially and in the correct order for a correct |
|
||||
* decode. Lost packets can be replaced with loss concealment by calling |
|
||||
* the decoder with a null pointer and zero length for the missing packet. |
|
||||
* |
|
||||
* A single codec state may only be accessed from a single thread at |
|
||||
* a time and any required locking must be performed by the caller. Separate |
|
||||
* streams must be decoded with separate decoder states and can be decoded |
|
||||
* in parallel unless the library was compiled with NONTHREADSAFE_PSEUDOSTACK |
|
||||
* defined. |
|
||||
* |
|
||||
*/ |
|
||||
|
|
||||
/** Opus decoder state.
|
|
||||
* This contains the complete state of an Opus decoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_decoder_create,opus_decoder_init |
|
||||
*/ |
|
||||
typedef struct OpusDecoder OpusDecoder; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusDecoder</code> structure.
|
|
||||
* @param [in] channels <tt>int</tt>: Number of channels. |
|
||||
* This must be 1 or 2. |
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_size(int channels); |
|
||||
|
|
||||
/** Allocates and initializes a decoder state.
|
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sample rate to decode at (Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
|
||||
* @param [out] error <tt>int*</tt>: #OPUS_OK Success or @ref opus_errorcodes |
|
||||
* |
|
||||
* Internally Opus stores data at 48000 Hz, so that should be the default |
|
||||
* value for Fs. However, the decoder can efficiently decode to buffers |
|
||||
* at 8, 12, 16, and 24 kHz so if for some reason the caller cannot use |
|
||||
* data at the full sample rate, or knows the compressed data doesn't |
|
||||
* use the full frequency range, it can request decoding at a reduced |
|
||||
* rate. Likewise, the decoder is capable of filling in either mono or |
|
||||
* interleaved stereo pcm buffers, at the caller's request. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusDecoder *opus_decoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int *error |
|
||||
); |
|
||||
|
|
||||
/** Initializes a previously allocated decoder state.
|
|
||||
* The state must be at least the size returned by opus_decoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of malloc. @see opus_decoder_create,opus_decoder_get_size |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state. |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate to decode to (Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) to decode |
|
||||
* @retval #OPUS_OK Success or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_decoder_init( |
|
||||
OpusDecoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels |
|
||||
) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Decode an Opus packet.
|
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
|
||||
* @param [in] len <tt>opus_int32</tt>: Number of bytes in payload* |
|
||||
* @param [out] pcm <tt>opus_int16*</tt>: Output signal (interleaved if 2 channels). length |
|
||||
* is frame_size*channels*sizeof(opus_int16) |
|
||||
* @param [in] frame_size Number of samples per channel of available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
|
||||
* not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
|
||||
* then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
|
||||
* FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
|
||||
* decoded. If no such data is available, the frame is decoded as if it were lost. |
|
||||
* @returns Number of decoded samples or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode( |
|
||||
OpusDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Decode an Opus packet with floating point output.
|
|
||||
* @param [in] st <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] data <tt>char*</tt>: Input payload. Use a NULL pointer to indicate packet loss |
|
||||
* @param [in] len <tt>opus_int32</tt>: Number of bytes in payload |
|
||||
* @param [out] pcm <tt>float*</tt>: Output signal (interleaved if 2 channels). length |
|
||||
* is frame_size*channels*sizeof(float) |
|
||||
* @param [in] frame_size Number of samples per channel of available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration (120ms; 5760 for 48kHz), this function will |
|
||||
* not be capable of decoding some packets. In the case of PLC (data==NULL) or FEC (decode_fec=1), |
|
||||
* then frame_size needs to be exactly the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the next incoming packet. For the PLC and |
|
||||
* FEC cases, frame_size <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param [in] decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band forward error correction data be |
|
||||
* decoded. If no such data is available the frame is decoded as if it were lost. |
|
||||
* @returns Number of decoded samples or @ref opus_errorcodes |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decode_float( |
|
||||
OpusDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
float *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Perform a CTL function on an Opus decoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated |
|
||||
* by a convenience macro. |
|
||||
* @param st <tt>OpusDecoder*</tt>: Decoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls or |
|
||||
* @ref opus_decoderctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_decoderctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_decoder_ctl(OpusDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Frees an <code>OpusDecoder</code> allocated by opus_decoder_create().
|
|
||||
* @param[in] st <tt>OpusDecoder*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_decoder_destroy(OpusDecoder *st); |
|
||||
|
|
||||
/** Parse an opus packet into one or more frames.
|
|
||||
* Opus_decode will perform this operation internally so most applications do |
|
||||
* not need to use this function. |
|
||||
* This function does not copy the frames, the returned pointers are pointers into |
|
||||
* the input packet. |
|
||||
* @param [in] data <tt>char*</tt>: Opus packet to be parsed |
|
||||
* @param [in] len <tt>opus_int32</tt>: size of data |
|
||||
* @param [out] out_toc <tt>char*</tt>: TOC pointer |
|
||||
* @param [out] frames <tt>char*[48]</tt> encapsulated frames |
|
||||
* @param [out] size <tt>opus_int16[48]</tt> sizes of the encapsulated frames |
|
||||
* @param [out] payload_offset <tt>int*</tt>: returns the position of the payload within the packet (in bytes) |
|
||||
* @returns number of frames |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_packet_parse( |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
unsigned char *out_toc, |
|
||||
const unsigned char *frames[48], |
|
||||
opus_int16 size[48], |
|
||||
int *payload_offset |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
/** Gets the bandwidth of an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet |
|
||||
* @retval OPUS_BANDWIDTH_NARROWBAND Narrowband (4kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_MEDIUMBAND Mediumband (6kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_WIDEBAND Wideband (8kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_SUPERWIDEBAND Superwideband (12kHz bandpass) |
|
||||
* @retval OPUS_BANDWIDTH_FULLBAND Fullband (20kHz bandpass) |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_bandwidth(const unsigned char *data) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples per frame from an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet. |
|
||||
* This must contain at least one byte of |
|
||||
* data. |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
|
||||
* This must be a multiple of 400, or |
|
||||
* inaccurate results will be returned. |
|
||||
* @returns Number of samples per frame. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_samples_per_frame(const unsigned char *data, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of channels from an Opus packet.
|
|
||||
* @param [in] data <tt>char*</tt>: Opus packet |
|
||||
* @returns Number of channels |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_channels(const unsigned char *data) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of frames in an Opus packet.
|
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @returns Number of frames |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_frames(const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples of an Opus packet.
|
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @param [in] Fs <tt>opus_int32</tt>: Sampling rate in Hz. |
|
||||
* This must be a multiple of 400, or |
|
||||
* inaccurate results will be returned. |
|
||||
* @returns Number of samples |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_packet_get_nb_samples(const unsigned char packet[], opus_int32 len, opus_int32 Fs) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Gets the number of samples of an Opus packet.
|
|
||||
* @param [in] dec <tt>OpusDecoder*</tt>: Decoder state |
|
||||
* @param [in] packet <tt>char*</tt>: Opus packet |
|
||||
* @param [in] len <tt>opus_int32</tt>: Length of packet |
|
||||
* @returns Number of samples |
|
||||
* @retval OPUS_BAD_ARG Insufficient data was passed to the function |
|
||||
* @retval OPUS_INVALID_PACKET The compressed data passed is corrupted or of an unsupported type |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_decoder_get_nb_samples(const OpusDecoder *dec, const unsigned char packet[], opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
|
||||
|
|
||||
/** Applies soft-clipping to bring a float signal within the [-1,1] range. If
|
|
||||
* the signal is already in that range, nothing is done. If there are values |
|
||||
* outside of [-1,1], then the signal is clipped as smoothly as possible to |
|
||||
* both fit in the range and avoid creating excessive distortion in the |
|
||||
* process. |
|
||||
* @param [in,out] pcm <tt>float*</tt>: Input PCM and modified PCM |
|
||||
* @param [in] frame_size <tt>int</tt> Number of samples per channel to process |
|
||||
* @param [in] channels <tt>int</tt>: Number of channels |
|
||||
* @param [in,out] softclip_mem <tt>float*</tt>: State memory for the soft clipping process (one float per channel, initialized to zero) |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_pcm_soft_clip(float *pcm, int frame_size, int channels, float *softclip_mem); |
|
||||
|
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_repacketizer Repacketizer
|
|
||||
* @{ |
|
||||
* |
|
||||
* The repacketizer can be used to merge multiple Opus packets into a single |
|
||||
* packet or alternatively to split Opus packets that have previously been |
|
||||
* merged. Splitting valid Opus packets is always guaranteed to succeed, |
|
||||
* whereas merging valid packets only succeeds if all frames have the same |
|
||||
* mode, bandwidth, and frame size, and when the total duration of the merged |
|
||||
* packet is no more than 120 ms. The 120 ms limit comes from the |
|
||||
* specification and limits decoder memory requirements at a point where |
|
||||
* framing overhead becomes negligible. |
|
||||
* |
|
||||
* The repacketizer currently only operates on elementary Opus |
|
||||
* streams. It will not manipualte multistream packets successfully, except in |
|
||||
* the degenerate case where they consist of data from a single stream. |
|
||||
* |
|
||||
* The repacketizing process starts with creating a repacketizer state, either |
|
||||
* by calling opus_repacketizer_create() or by allocating the memory yourself, |
|
||||
* e.g., |
|
||||
* @code |
|
||||
* OpusRepacketizer *rp; |
|
||||
* rp = (OpusRepacketizer*)malloc(opus_repacketizer_get_size()); |
|
||||
* if (rp != NULL) |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* @endcode |
|
||||
* |
|
||||
* Then the application should submit packets with opus_repacketizer_cat(), |
|
||||
* extract new packets with opus_repacketizer_out() or |
|
||||
* opus_repacketizer_out_range(), and then reset the state for the next set of |
|
||||
* input packets via opus_repacketizer_init(). |
|
||||
* |
|
||||
* For example, to split a sequence of packets into individual frames: |
|
||||
* @code |
|
||||
* unsigned char *data; |
|
||||
* int len; |
|
||||
* while (get_next_packet(&data, &len)) |
|
||||
* { |
|
||||
* unsigned char out[1276]; |
|
||||
* opus_int32 out_len; |
|
||||
* int nb_frames; |
|
||||
* int err; |
|
||||
* int i; |
|
||||
* err = opus_repacketizer_cat(rp, data, len); |
|
||||
* if (err != OPUS_OK) |
|
||||
* { |
|
||||
* release_packet(data); |
|
||||
* return err; |
|
||||
* } |
|
||||
* nb_frames = opus_repacketizer_get_nb_frames(rp); |
|
||||
* for (i = 0; i < nb_frames; i++) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out_range(rp, i, i+1, out, sizeof(out)); |
|
||||
* if (out_len < 0) |
|
||||
* { |
|
||||
* release_packet(data); |
|
||||
* return (int)out_len; |
|
||||
* } |
|
||||
* output_next_packet(out, out_len); |
|
||||
* } |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* release_packet(data); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* Alternatively, to combine a sequence of frames into packets that each |
|
||||
* contain up to <code>TARGET_DURATION_MS</code> milliseconds of data: |
|
||||
* @code |
|
||||
* // The maximum number of packets with duration TARGET_DURATION_MS occurs
|
|
||||
* // when the frame size is 2.5 ms, for a total of (TARGET_DURATION_MS*2/5)
|
|
||||
* // packets.
|
|
||||
* unsigned char *data[(TARGET_DURATION_MS*2/5)+1]; |
|
||||
* opus_int32 len[(TARGET_DURATION_MS*2/5)+1]; |
|
||||
* int nb_packets; |
|
||||
* unsigned char out[1277*(TARGET_DURATION_MS*2/2)]; |
|
||||
* opus_int32 out_len; |
|
||||
* int prev_toc; |
|
||||
* nb_packets = 0; |
|
||||
* while (get_next_packet(data+nb_packets, len+nb_packets)) |
|
||||
* { |
|
||||
* int nb_frames; |
|
||||
* int err; |
|
||||
* nb_frames = opus_packet_get_nb_frames(data[nb_packets], len[nb_packets]); |
|
||||
* if (nb_frames < 1) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return nb_frames; |
|
||||
* } |
|
||||
* nb_frames += opus_repacketizer_get_nb_frames(rp); |
|
||||
* // If adding the next packet would exceed our target, or it has an
|
|
||||
* // incompatible TOC sequence, output the packets we already have before
|
|
||||
* // submitting it.
|
|
||||
* // N.B., The nb_packets > 0 check ensures we've submitted at least one
|
|
||||
* // packet since the last call to opus_repacketizer_init(). Otherwise a
|
|
||||
* // single packet longer than TARGET_DURATION_MS would cause us to try to
|
|
||||
* // output an (invalid) empty packet. It also ensures that prev_toc has
|
|
||||
* // been set to a valid value. Additionally, len[nb_packets] > 0 is
|
|
||||
* // guaranteed by the call to opus_packet_get_nb_frames() above, so the
|
|
||||
* // reference to data[nb_packets][0] should be valid.
|
|
||||
* if (nb_packets > 0 && ( |
|
||||
* ((prev_toc & 0xFC) != (data[nb_packets][0] & 0xFC)) || |
|
||||
* opus_packet_get_samples_per_frame(data[nb_packets], 48000)*nb_frames > |
|
||||
* TARGET_DURATION_MS*48)) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
|
||||
* if (out_len < 0) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return (int)out_len; |
|
||||
* } |
|
||||
* output_next_packet(out, out_len); |
|
||||
* opus_repacketizer_init(rp); |
|
||||
* release_packets(data, nb_packets); |
|
||||
* data[0] = data[nb_packets]; |
|
||||
* len[0] = len[nb_packets]; |
|
||||
* nb_packets = 0; |
|
||||
* } |
|
||||
* err = opus_repacketizer_cat(rp, data[nb_packets], len[nb_packets]); |
|
||||
* if (err != OPUS_OK) |
|
||||
* { |
|
||||
* release_packets(data, nb_packets+1); |
|
||||
* return err; |
|
||||
* } |
|
||||
* prev_toc = data[nb_packets][0]; |
|
||||
* nb_packets++; |
|
||||
* } |
|
||||
* // Output the final, partial packet.
|
|
||||
* if (nb_packets > 0) |
|
||||
* { |
|
||||
* out_len = opus_repacketizer_out(rp, out, sizeof(out)); |
|
||||
* release_packets(data, nb_packets); |
|
||||
* if (out_len < 0) |
|
||||
* return (int)out_len; |
|
||||
* output_next_packet(out, out_len); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* An alternate way of merging packets is to simply call opus_repacketizer_cat() |
|
||||
* unconditionally until it fails. At that point, the merged packet can be |
|
||||
* obtained with opus_repacketizer_out() and the input packet for which |
|
||||
* opus_repacketizer_cat() needs to be re-added to a newly reinitialized |
|
||||
* repacketizer state. |
|
||||
*/ |
|
||||
|
|
||||
typedef struct OpusRepacketizer OpusRepacketizer; |
|
||||
|
|
||||
/** Gets the size of an <code>OpusRepacketizer</code> structure.
|
|
||||
* @returns The size in bytes. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_size(void); |
|
||||
|
|
||||
/** (Re)initializes a previously allocated repacketizer state.
|
|
||||
* The state must be at least the size returned by opus_repacketizer_get_size(). |
|
||||
* This can be used for applications which use their own allocator instead of |
|
||||
* malloc(). |
|
||||
* It must also be called to reset the queue of packets waiting to be |
|
||||
* repacketized, which is necessary if the maximum packet duration of 120 ms |
|
||||
* is reached or if you wish to submit packets with a different Opus |
|
||||
* configuration (coding mode, audio bandwidth, frame size, or channel count). |
|
||||
* Failure to do so will prevent a new packet from being added with |
|
||||
* opus_repacketizer_cat(). |
|
||||
* @see opus_repacketizer_create |
|
||||
* @see opus_repacketizer_get_size |
|
||||
* @see opus_repacketizer_cat |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to |
|
||||
* (re)initialize. |
|
||||
* @returns A pointer to the same repacketizer state that was passed in. |
|
||||
*/ |
|
||||
OPUS_EXPORT OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Allocates memory and initializes the new repacketizer with
|
|
||||
* opus_repacketizer_init(). |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusRepacketizer *opus_repacketizer_create(void); |
|
||||
|
|
||||
/** Frees an <code>OpusRepacketizer</code> allocated by
|
|
||||
* opus_repacketizer_create(). |
|
||||
* @param[in] rp <tt>OpusRepacketizer*</tt>: State to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_repacketizer_destroy(OpusRepacketizer *rp); |
|
||||
|
|
||||
/** Add a packet to the current repacketizer state.
|
|
||||
* This packet must match the configuration of any packets already submitted |
|
||||
* for repacketization since the last call to opus_repacketizer_init(). |
|
||||
* This means that it must have the same coding mode, audio bandwidth, frame |
|
||||
* size, and channel count. |
|
||||
* This can be checked in advance by examining the top 6 bits of the first |
|
||||
* byte of the packet, and ensuring they match the top 6 bits of the first |
|
||||
* byte of any previously submitted packet. |
|
||||
* The total duration of audio in the repacketizer state also must not exceed |
|
||||
* 120 ms, the maximum duration of a single packet, after adding this packet. |
|
||||
* |
|
||||
* The contents of the current repacketizer state can be extracted into new |
|
||||
* packets using opus_repacketizer_out() or opus_repacketizer_out_range(). |
|
||||
* |
|
||||
* In order to add a packet with a different configuration or to add more |
|
||||
* audio beyond 120 ms, you must clear the repacketizer state by calling |
|
||||
* opus_repacketizer_init(). |
|
||||
* If a packet is too large to add to the current repacketizer state, no part |
|
||||
* of it is added, even if it contains multiple frames, some of which might |
|
||||
* fit. |
|
||||
* If you wish to be able to add parts of such packets, you should first use |
|
||||
* another repacketizer to split the packet into pieces and add them |
|
||||
* individually. |
|
||||
* @see opus_repacketizer_out_range |
|
||||
* @see opus_repacketizer_out |
|
||||
* @see opus_repacketizer_init |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state to which to |
|
||||
* add the packet. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: The packet data. |
|
||||
* The application must ensure |
|
||||
* this pointer remains valid |
|
||||
* until the next call to |
|
||||
* opus_repacketizer_init() or |
|
||||
* opus_repacketizer_destroy(). |
|
||||
* @param len <tt>opus_int32</tt>: The number of bytes in the packet data. |
|
||||
* @returns An error code indicating whether or not the operation succeeded. |
|
||||
* @retval #OPUS_OK The packet's contents have been added to the repacketizer |
|
||||
* state. |
|
||||
* @retval #OPUS_INVALID_PACKET The packet did not have a valid TOC sequence, |
|
||||
* the packet's TOC sequence was not compatible |
|
||||
* with previously submitted packets (because |
|
||||
* the coding mode, audio bandwidth, frame size, |
|
||||
* or channel count did not match), or adding |
|
||||
* this packet would increase the total amount of |
|
||||
* audio stored in the repacketizer state to more |
|
||||
* than 120 ms. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_repacketizer_cat(OpusRepacketizer *rp, const unsigned char *data, opus_int32 len) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2); |
|
||||
|
|
||||
|
|
||||
/** Construct a new packet from data previously submitted to the repacketizer
|
|
||||
* state via opus_repacketizer_cat(). |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
|
||||
* construct the new packet. |
|
||||
* @param begin <tt>int</tt>: The index of the first frame in the current |
|
||||
* repacketizer state to include in the output. |
|
||||
* @param end <tt>int</tt>: One past the index of the last frame in the |
|
||||
* current repacketizer state to include in the |
|
||||
* output. |
|
||||
* @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
|
||||
* store the output packet. |
|
||||
* @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
|
||||
* the output buffer. In order to guarantee |
|
||||
* success, this should be at least |
|
||||
* <code>1276</code> for a single frame, |
|
||||
* or for multiple frames, |
|
||||
* <code>1277*(end-begin)</code>. |
|
||||
* However, <code>1*(end-begin)</code> plus |
|
||||
* the size of all packet data submitted to |
|
||||
* the repacketizer since the last call to |
|
||||
* opus_repacketizer_init() or |
|
||||
* opus_repacketizer_create() is also |
|
||||
* sufficient, and possibly much smaller. |
|
||||
* @returns The total size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG <code>[begin,end)</code> was an invalid range of |
|
||||
* frames (begin < 0, begin >= end, or end > |
|
||||
* opus_repacketizer_get_nb_frames()). |
|
||||
* @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
|
||||
* complete output packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out_range(OpusRepacketizer *rp, int begin, int end, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Return the total number of frames contained in packet data submitted to
|
|
||||
* the repacketizer state so far via opus_repacketizer_cat() since the last |
|
||||
* call to opus_repacketizer_init() or opus_repacketizer_create(). |
|
||||
* This defines the valid range of packets that can be extracted with |
|
||||
* opus_repacketizer_out_range() or opus_repacketizer_out(). |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state containing the |
|
||||
* frames. |
|
||||
* @returns The total number of frames contained in the packet data submitted |
|
||||
* to the repacketizer state. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_repacketizer_get_nb_frames(OpusRepacketizer *rp) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Construct a new packet from data previously submitted to the repacketizer
|
|
||||
* state via opus_repacketizer_cat(). |
|
||||
* This is a convenience routine that returns all the data submitted so far |
|
||||
* in a single packet. |
|
||||
* It is equivalent to calling |
|
||||
* @code |
|
||||
* opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp), |
|
||||
* data, maxlen) |
|
||||
* @endcode |
|
||||
* @param rp <tt>OpusRepacketizer*</tt>: The repacketizer state from which to |
|
||||
* construct the new packet. |
|
||||
* @param[out] data <tt>const unsigned char*</tt>: The buffer in which to |
|
||||
* store the output packet. |
|
||||
* @param maxlen <tt>opus_int32</tt>: The maximum number of bytes to store in |
|
||||
* the output buffer. In order to guarantee |
|
||||
* success, this should be at least |
|
||||
* <code>1277*opus_repacketizer_get_nb_frames(rp)</code>. |
|
||||
* However, |
|
||||
* <code>1*opus_repacketizer_get_nb_frames(rp)</code> |
|
||||
* plus the size of all packet data |
|
||||
* submitted to the repacketizer since the |
|
||||
* last call to opus_repacketizer_init() or |
|
||||
* opus_repacketizer_create() is also |
|
||||
* sufficient, and possibly much smaller. |
|
||||
* @returns The total size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BUFFER_TOO_SMALL \a maxlen was insufficient to contain the |
|
||||
* complete output packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_repacketizer_out(OpusRepacketizer *rp, unsigned char *data, opus_int32 maxlen) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Pads a given Opus packet to a larger size (possibly changing the TOC sequence).
|
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to pad. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
|
||||
* This must be at least as large as len. |
|
||||
* @returns an error code |
|
||||
* @retval #OPUS_OK \a on success. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len); |
|
||||
|
|
||||
/** Remove all padding from a given Opus packet and rewrite the TOC sequence to
|
|
||||
* minimize space usage. |
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to strip. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @returns The new size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_packet_unpad(unsigned char *data, opus_int32 len); |
|
||||
|
|
||||
/** Pads a given Opus multi-stream packet to a larger size (possibly changing the TOC sequence).
|
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to pad. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param new_len <tt>opus_int32</tt>: The desired size of the packet after padding. |
|
||||
* This must be at least 1. |
|
||||
* @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
|
||||
* This must be at least as large as len. |
|
||||
* @returns an error code |
|
||||
* @retval #OPUS_OK \a on success. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_packet_pad(unsigned char *data, opus_int32 len, opus_int32 new_len, int nb_streams); |
|
||||
|
|
||||
/** Remove all padding from a given Opus multi-stream packet and rewrite the TOC sequence to
|
|
||||
* minimize space usage. |
|
||||
* @param[in,out] data <tt>const unsigned char*</tt>: The buffer containing the |
|
||||
* packet to strip. |
|
||||
* @param len <tt>opus_int32</tt>: The size of the packet. |
|
||||
* This must be at least 1. |
|
||||
* @param nb_streams <tt>opus_int32</tt>: The number of streams (not channels) in the packet. |
|
||||
* This must be at least 1. |
|
||||
* @returns The new size of the output packet on success, or an error code |
|
||||
* on failure. |
|
||||
* @retval #OPUS_BAD_ARG \a len was less than 1 or new_len was less than len. |
|
||||
* @retval #OPUS_INVALID_PACKET \a data did not contain a valid Opus packet. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_packet_unpad(unsigned char *data, opus_int32 len, int nb_streams); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_H */ |
|
||||
@ -1,799 +0,0 @@ |
|||||
/* Copyright (c) 2010-2011 Xiph.Org Foundation, Skype Limited
|
|
||||
Written by Jean-Marc Valin and Koen Vos */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus_defines.h |
|
||||
* @brief Opus reference implementation constants |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_DEFINES_H |
|
||||
#define OPUS_DEFINES_H |
|
||||
|
|
||||
#include "opus_types.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/** @defgroup opus_errorcodes Error codes
|
|
||||
* @{ |
|
||||
*/ |
|
||||
/** No error @hideinitializer*/ |
|
||||
#define OPUS_OK 0 |
|
||||
/** One or more invalid/out of range arguments @hideinitializer*/ |
|
||||
#define OPUS_BAD_ARG -1 |
|
||||
/** Not enough bytes allocated in the buffer @hideinitializer*/ |
|
||||
#define OPUS_BUFFER_TOO_SMALL -2 |
|
||||
/** An internal error was detected @hideinitializer*/ |
|
||||
#define OPUS_INTERNAL_ERROR -3 |
|
||||
/** The compressed data passed is corrupted @hideinitializer*/ |
|
||||
#define OPUS_INVALID_PACKET -4 |
|
||||
/** Invalid/unsupported request number @hideinitializer*/ |
|
||||
#define OPUS_UNIMPLEMENTED -5 |
|
||||
/** An encoder or decoder structure is invalid or already freed @hideinitializer*/ |
|
||||
#define OPUS_INVALID_STATE -6 |
|
||||
/** Memory allocation has failed @hideinitializer*/ |
|
||||
#define OPUS_ALLOC_FAIL -7 |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @cond OPUS_INTERNAL_DOC */ |
|
||||
/**Export control for opus functions */ |
|
||||
|
|
||||
#ifndef OPUS_EXPORT |
|
||||
# if defined(WIN32) |
|
||||
# if defined(OPUS_BUILD) && defined(DLL_EXPORT) |
|
||||
# define OPUS_EXPORT __declspec(dllexport) |
|
||||
# else |
|
||||
# define OPUS_EXPORT |
|
||||
# endif |
|
||||
# elif defined(__GNUC__) && defined(OPUS_BUILD) |
|
||||
# define OPUS_EXPORT __attribute__ ((visibility ("default"))) |
|
||||
# else |
|
||||
# define OPUS_EXPORT |
|
||||
# endif |
|
||||
#endif |
|
||||
|
|
||||
# if !defined(OPUS_GNUC_PREREQ) |
|
||||
# if defined(__GNUC__)&&defined(__GNUC_MINOR__) |
|
||||
# define OPUS_GNUC_PREREQ(_maj,_min) \ |
|
||||
((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) |
|
||||
# else |
|
||||
# define OPUS_GNUC_PREREQ(_maj,_min) 0 |
|
||||
# endif |
|
||||
# endif |
|
||||
|
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
|
||||
# if OPUS_GNUC_PREREQ(3,0) |
|
||||
# define OPUS_RESTRICT __restrict__ |
|
||||
# elif (defined(_MSC_VER) && _MSC_VER >= 1400) |
|
||||
# define OPUS_RESTRICT __restrict |
|
||||
# else |
|
||||
# define OPUS_RESTRICT |
|
||||
# endif |
|
||||
#else |
|
||||
# define OPUS_RESTRICT restrict |
|
||||
#endif |
|
||||
|
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) |
|
||||
# if OPUS_GNUC_PREREQ(2,7) |
|
||||
# define OPUS_INLINE __inline__ |
|
||||
# elif (defined(_MSC_VER)) |
|
||||
# define OPUS_INLINE __inline |
|
||||
# else |
|
||||
# define OPUS_INLINE |
|
||||
# endif |
|
||||
#else |
|
||||
# define OPUS_INLINE inline |
|
||||
#endif |
|
||||
|
|
||||
/**Warning attributes for opus functions
|
|
||||
* NONNULL is not used in OPUS_BUILD to avoid the compiler optimizing out |
|
||||
* some paranoid null checks. */ |
|
||||
#if defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
|
||||
# define OPUS_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) |
|
||||
#else |
|
||||
# define OPUS_WARN_UNUSED_RESULT |
|
||||
#endif |
|
||||
#if !defined(OPUS_BUILD) && defined(__GNUC__) && OPUS_GNUC_PREREQ(3, 4) |
|
||||
# define OPUS_ARG_NONNULL(_x) __attribute__ ((__nonnull__(_x))) |
|
||||
#else |
|
||||
# define OPUS_ARG_NONNULL(_x) |
|
||||
#endif |
|
||||
|
|
||||
/** These are the actual Encoder CTL ID numbers.
|
|
||||
* They should not be used directly by applications. |
|
||||
* In general, SETs should be even and GETs should be odd.*/ |
|
||||
#define OPUS_SET_APPLICATION_REQUEST 4000 |
|
||||
#define OPUS_GET_APPLICATION_REQUEST 4001 |
|
||||
#define OPUS_SET_BITRATE_REQUEST 4002 |
|
||||
#define OPUS_GET_BITRATE_REQUEST 4003 |
|
||||
#define OPUS_SET_MAX_BANDWIDTH_REQUEST 4004 |
|
||||
#define OPUS_GET_MAX_BANDWIDTH_REQUEST 4005 |
|
||||
#define OPUS_SET_VBR_REQUEST 4006 |
|
||||
#define OPUS_GET_VBR_REQUEST 4007 |
|
||||
#define OPUS_SET_BANDWIDTH_REQUEST 4008 |
|
||||
#define OPUS_GET_BANDWIDTH_REQUEST 4009 |
|
||||
#define OPUS_SET_COMPLEXITY_REQUEST 4010 |
|
||||
#define OPUS_GET_COMPLEXITY_REQUEST 4011 |
|
||||
#define OPUS_SET_INBAND_FEC_REQUEST 4012 |
|
||||
#define OPUS_GET_INBAND_FEC_REQUEST 4013 |
|
||||
#define OPUS_SET_PACKET_LOSS_PERC_REQUEST 4014 |
|
||||
#define OPUS_GET_PACKET_LOSS_PERC_REQUEST 4015 |
|
||||
#define OPUS_SET_DTX_REQUEST 4016 |
|
||||
#define OPUS_GET_DTX_REQUEST 4017 |
|
||||
#define OPUS_SET_VBR_CONSTRAINT_REQUEST 4020 |
|
||||
#define OPUS_GET_VBR_CONSTRAINT_REQUEST 4021 |
|
||||
#define OPUS_SET_FORCE_CHANNELS_REQUEST 4022 |
|
||||
#define OPUS_GET_FORCE_CHANNELS_REQUEST 4023 |
|
||||
#define OPUS_SET_SIGNAL_REQUEST 4024 |
|
||||
#define OPUS_GET_SIGNAL_REQUEST 4025 |
|
||||
#define OPUS_GET_LOOKAHEAD_REQUEST 4027 |
|
||||
/* #define OPUS_RESET_STATE 4028 */ |
|
||||
#define OPUS_GET_SAMPLE_RATE_REQUEST 4029 |
|
||||
#define OPUS_GET_FINAL_RANGE_REQUEST 4031 |
|
||||
#define OPUS_GET_PITCH_REQUEST 4033 |
|
||||
#define OPUS_SET_GAIN_REQUEST 4034 |
|
||||
#define OPUS_GET_GAIN_REQUEST 4045 /* Should have been 4035 */ |
|
||||
#define OPUS_SET_LSB_DEPTH_REQUEST 4036 |
|
||||
#define OPUS_GET_LSB_DEPTH_REQUEST 4037 |
|
||||
#define OPUS_GET_LAST_PACKET_DURATION_REQUEST 4039 |
|
||||
#define OPUS_SET_EXPERT_FRAME_DURATION_REQUEST 4040 |
|
||||
#define OPUS_GET_EXPERT_FRAME_DURATION_REQUEST 4041 |
|
||||
#define OPUS_SET_PREDICTION_DISABLED_REQUEST 4042 |
|
||||
#define OPUS_GET_PREDICTION_DISABLED_REQUEST 4043 |
|
||||
/* Don't use 4045, it's already taken by OPUS_GET_GAIN_REQUEST */ |
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST 4046 |
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST 4047 |
|
||||
#define OPUS_GET_IN_DTX_REQUEST 4049 |
|
||||
|
|
||||
/** Defines for the presence of extended APIs. */ |
|
||||
#define OPUS_HAVE_OPUS_PROJECTION_H |
|
||||
|
|
||||
/* Macros to trigger compilation errors when the wrong types are provided to a CTL */ |
|
||||
#define __opus_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x)) |
|
||||
#define __opus_check_int_ptr(ptr) ((ptr) + ((ptr) - (opus_int32*)(ptr))) |
|
||||
#define __opus_check_uint_ptr(ptr) ((ptr) + ((ptr) - (opus_uint32*)(ptr))) |
|
||||
#define __opus_check_val16_ptr(ptr) ((ptr) + ((ptr) - (opus_val16*)(ptr))) |
|
||||
/** @endcond */ |
|
||||
|
|
||||
/** @defgroup opus_ctlvalues Pre-defined values for CTL interface
|
|
||||
* @see opus_genericctls, opus_encoderctls |
|
||||
* @{ |
|
||||
*/ |
|
||||
/* Values for the various encoder CTLs */ |
|
||||
#define OPUS_AUTO -1000 /**<Auto/default setting @hideinitializer*/ |
|
||||
#define OPUS_BITRATE_MAX -1 /**<Maximum bitrate @hideinitializer*/ |
|
||||
|
|
||||
/** Best for most VoIP/videoconference applications where listening quality and intelligibility matter most
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_VOIP 2048 |
|
||||
/** Best for broadcast/high-fidelity application where the decoded audio should be as close as possible to the input
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_AUDIO 2049 |
|
||||
/** Only use when lowest-achievable latency is what matters most. Voice-optimized modes cannot be used.
|
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_APPLICATION_RESTRICTED_LOWDELAY 2051 |
|
||||
|
|
||||
#define OPUS_SIGNAL_VOICE 3001 /**< Signal being encoded is voice */ |
|
||||
#define OPUS_SIGNAL_MUSIC 3002 /**< Signal being encoded is music */ |
|
||||
#define OPUS_BANDWIDTH_NARROWBAND 1101 /**< 4 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_MEDIUMBAND 1102 /**< 6 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_WIDEBAND 1103 /**< 8 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_SUPERWIDEBAND 1104 /**<12 kHz bandpass @hideinitializer*/ |
|
||||
#define OPUS_BANDWIDTH_FULLBAND 1105 /**<20 kHz bandpass @hideinitializer*/ |
|
||||
|
|
||||
#define OPUS_FRAMESIZE_ARG 5000 /**< Select frame size from the argument (default) */ |
|
||||
#define OPUS_FRAMESIZE_2_5_MS 5001 /**< Use 2.5 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_5_MS 5002 /**< Use 5 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_10_MS 5003 /**< Use 10 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_20_MS 5004 /**< Use 20 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_40_MS 5005 /**< Use 40 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_60_MS 5006 /**< Use 60 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_80_MS 5007 /**< Use 80 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_100_MS 5008 /**< Use 100 ms frames */ |
|
||||
#define OPUS_FRAMESIZE_120_MS 5009 /**< Use 120 ms frames */ |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
|
|
||||
/** @defgroup opus_encoderctls Encoder related CTLs
|
|
||||
* |
|
||||
* These are convenience macros for use with the \c opus_encode_ctl |
|
||||
* interface. They are used to generate the appropriate series of |
|
||||
* arguments for that call, passing the correct type, size and so |
|
||||
* on as expected for each particular request. |
|
||||
* |
|
||||
* Some usage examples: |
|
||||
* |
|
||||
* @code |
|
||||
* int ret; |
|
||||
* ret = opus_encoder_ctl(enc_ctx, OPUS_SET_BANDWIDTH(OPUS_AUTO)); |
|
||||
* if (ret != OPUS_OK) return ret; |
|
||||
* |
|
||||
* opus_int32 rate; |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&rate)); |
|
||||
* |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
|
||||
* @endcode |
|
||||
* |
|
||||
* @see opus_genericctls, opus_encoder |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Configures the encoder's computational complexity.
|
|
||||
* The supported range is 0-10 inclusive with 10 representing the highest complexity. |
|
||||
* @see OPUS_GET_COMPLEXITY |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: 0-10, inclusive. |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_COMPLEXITY(x) OPUS_SET_COMPLEXITY_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's complexity configuration.
|
|
||||
* @see OPUS_SET_COMPLEXITY |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns a value in the range 0-10, |
|
||||
* inclusive. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_COMPLEXITY(x) OPUS_GET_COMPLEXITY_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the bitrate in the encoder.
|
|
||||
* Rates from 500 to 512000 bits per second are meaningful, as well as the |
|
||||
* special values #OPUS_AUTO and #OPUS_BITRATE_MAX. |
|
||||
* The value #OPUS_BITRATE_MAX can be used to cause the codec to use as much |
|
||||
* rate as it can, which is useful for controlling the rate by adjusting the |
|
||||
* output buffer size. |
|
||||
* @see OPUS_GET_BITRATE |
|
||||
* @param[in] x <tt>opus_int32</tt>: Bitrate in bits per second. The default |
|
||||
* is determined based on the number of |
|
||||
* channels and the input sampling rate. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_BITRATE(x) OPUS_SET_BITRATE_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's bitrate configuration.
|
|
||||
* @see OPUS_SET_BITRATE |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns the bitrate in bits per second. |
|
||||
* The default is determined based on the |
|
||||
* number of channels and the input |
|
||||
* sampling rate. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_BITRATE(x) OPUS_GET_BITRATE_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Enables or disables variable bitrate (VBR) in the encoder.
|
|
||||
* The configured bitrate may not be met exactly because frames must |
|
||||
* be an integer number of bytes in length. |
|
||||
* @see OPUS_GET_VBR |
|
||||
* @see OPUS_SET_VBR_CONSTRAINT |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Hard CBR. For LPC/hybrid modes at very low bit-rate, this can |
|
||||
* cause noticeable quality degradation.</dd> |
|
||||
* <dt>1</dt><dd>VBR (default). The exact type of VBR is controlled by |
|
||||
* #OPUS_SET_VBR_CONSTRAINT.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_VBR(x) OPUS_SET_VBR_REQUEST, __opus_check_int(x) |
|
||||
/** Determine if variable bitrate (VBR) is enabled in the encoder.
|
|
||||
* @see OPUS_SET_VBR |
|
||||
* @see OPUS_GET_VBR_CONSTRAINT |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Hard CBR.</dd> |
|
||||
* <dt>1</dt><dd>VBR (default). The exact type of VBR may be retrieved via |
|
||||
* #OPUS_GET_VBR_CONSTRAINT.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_VBR(x) OPUS_GET_VBR_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Enables or disables constrained VBR in the encoder.
|
|
||||
* This setting is ignored when the encoder is in CBR mode. |
|
||||
* @warning Only the MDCT mode of Opus currently heeds the constraint. |
|
||||
* Speech mode ignores it completely, hybrid mode may fail to obey it |
|
||||
* if the LPC layer uses more bitrate than the constraint would have |
|
||||
* permitted. |
|
||||
* @see OPUS_GET_VBR_CONSTRAINT |
|
||||
* @see OPUS_SET_VBR |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Unconstrained VBR.</dd> |
|
||||
* <dt>1</dt><dd>Constrained VBR (default). This creates a maximum of one |
|
||||
* frame of buffering delay assuming a transport with a |
|
||||
* serialization speed of the nominal bitrate.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_VBR_CONSTRAINT(x) OPUS_SET_VBR_CONSTRAINT_REQUEST, __opus_check_int(x) |
|
||||
/** Determine if constrained VBR is enabled in the encoder.
|
|
||||
* @see OPUS_SET_VBR_CONSTRAINT |
|
||||
* @see OPUS_GET_VBR |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Unconstrained VBR.</dd> |
|
||||
* <dt>1</dt><dd>Constrained VBR (default).</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_VBR_CONSTRAINT(x) OPUS_GET_VBR_CONSTRAINT_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures mono/stereo forcing in the encoder.
|
|
||||
* This can force the encoder to produce packets encoded as either mono or |
|
||||
* stereo, regardless of the format of the input audio. This is useful when |
|
||||
* the caller knows that the input signal is currently a mono source embedded |
|
||||
* in a stereo stream. |
|
||||
* @see OPUS_GET_FORCE_CHANNELS |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
|
||||
* <dt>1</dt> <dd>Forced mono</dd> |
|
||||
* <dt>2</dt> <dd>Forced stereo</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_FORCE_CHANNELS(x) OPUS_SET_FORCE_CHANNELS_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's forced channel configuration.
|
|
||||
* @see OPUS_SET_FORCE_CHANNELS |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt><dd>Not forced (default)</dd> |
|
||||
* <dt>1</dt> <dd>Forced mono</dd> |
|
||||
* <dt>2</dt> <dd>Forced stereo</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_FORCE_CHANNELS(x) OPUS_GET_FORCE_CHANNELS_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the maximum bandpass that the encoder will select automatically.
|
|
||||
* Applications should normally use this instead of #OPUS_SET_BANDWIDTH |
|
||||
* (leaving that set to the default, #OPUS_AUTO). This allows the |
|
||||
* application to set an upper bound based on the type of input it is |
|
||||
* providing, but still gives the encoder the freedom to reduce the bandpass |
|
||||
* when the bitrate becomes too low, for better overall quality. |
|
||||
* @see OPUS_GET_MAX_BANDWIDTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_MAX_BANDWIDTH(x) OPUS_SET_MAX_BANDWIDTH_REQUEST, __opus_check_int(x) |
|
||||
|
|
||||
/** Gets the encoder's configured maximum allowed bandpass.
|
|
||||
* @see OPUS_SET_MAX_BANDWIDTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband (default)</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_MAX_BANDWIDTH(x) OPUS_GET_MAX_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Sets the encoder's bandpass to a specific value.
|
|
||||
* This prevents the encoder from automatically selecting the bandpass based |
|
||||
* on the available bitrate. If an application knows the bandpass of the input |
|
||||
* audio it is providing, it should normally use #OPUS_SET_MAX_BANDWIDTH |
|
||||
* instead, which still gives the encoder the freedom to reduce the bandpass |
|
||||
* when the bitrate becomes too low, for better overall quality. |
|
||||
* @see OPUS_GET_BANDWIDTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_BANDWIDTH(x) OPUS_SET_BANDWIDTH_REQUEST, __opus_check_int(x) |
|
||||
|
|
||||
/** Configures the type of signal being encoded.
|
|
||||
* This is a hint which helps the encoder's mode selection. |
|
||||
* @see OPUS_GET_SIGNAL |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
|
||||
* <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_SIGNAL(x) OPUS_SET_SIGNAL_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured signal type.
|
|
||||
* @see OPUS_SET_SIGNAL |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_SIGNAL_VOICE</dt><dd>Bias thresholds towards choosing LPC or Hybrid modes.</dd> |
|
||||
* <dt>#OPUS_SIGNAL_MUSIC</dt><dd>Bias thresholds towards choosing MDCT modes.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_SIGNAL(x) OPUS_GET_SIGNAL_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
|
|
||||
/** Configures the encoder's intended application.
|
|
||||
* The initial value is a mandatory argument to the encoder_create function. |
|
||||
* @see OPUS_GET_APPLICATION |
|
||||
* @param[in] x <tt>opus_int32</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_APPLICATION(x) OPUS_SET_APPLICATION_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured application.
|
|
||||
* @see OPUS_SET_APPLICATION |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_APPLICATION(x) OPUS_GET_APPLICATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the total samples of delay added by the entire codec.
|
|
||||
* This can be queried by the encoder and then the provided number of samples can be |
|
||||
* skipped on from the start of the decoder's output to provide time aligned input |
|
||||
* and output. From the perspective of a decoding application the real data begins this many |
|
||||
* samples late. |
|
||||
* |
|
||||
* The decoder contribution to this delay is identical for all decoders, but the |
|
||||
* encoder portion of the delay may vary from implementation to implementation, |
|
||||
* version to version, or even depend on the encoder's initial configuration. |
|
||||
* Applications needing delay compensation should call this CTL rather than |
|
||||
* hard-coding a value. |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Number of lookahead samples |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LOOKAHEAD(x) OPUS_GET_LOOKAHEAD_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of inband forward error correction (FEC).
|
|
||||
* @note This is only applicable to the LPC layer |
|
||||
* @see OPUS_GET_INBAND_FEC |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Disable inband FEC (default).</dd> |
|
||||
* <dt>1</dt><dd>Enable inband FEC.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x) |
|
||||
/** Gets encoder's configured use of inband forward error correction.
|
|
||||
* @see OPUS_SET_INBAND_FEC |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Inband FEC disabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Inband FEC enabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's expected packet loss percentage.
|
|
||||
* Higher values trigger progressively more loss resistant behavior in the encoder |
|
||||
* at the expense of quality at a given bitrate in the absence of packet loss, but |
|
||||
* greater quality under loss. |
|
||||
* @see OPUS_GET_PACKET_LOSS_PERC |
|
||||
* @param[in] x <tt>opus_int32</tt>: Loss percentage in the range 0-100, inclusive (default: 0). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PACKET_LOSS_PERC(x) OPUS_SET_PACKET_LOSS_PERC_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured packet loss percentage.
|
|
||||
* @see OPUS_SET_PACKET_LOSS_PERC |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns the configured loss percentage |
|
||||
* in the range 0-100, inclusive (default: 0). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PACKET_LOSS_PERC(x) OPUS_GET_PACKET_LOSS_PERC_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of discontinuous transmission (DTX).
|
|
||||
* @note This is only applicable to the LPC layer |
|
||||
* @see OPUS_GET_DTX |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Disable DTX (default).</dd> |
|
||||
* <dt>1</dt><dd>Enabled DTX.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_DTX(x) OPUS_SET_DTX_REQUEST, __opus_check_int(x) |
|
||||
/** Gets encoder's configured use of discontinuous transmission.
|
|
||||
* @see OPUS_SET_DTX |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>DTX disabled (default).</dd> |
|
||||
* <dt>1</dt><dd>DTX enabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_DTX(x) OPUS_GET_DTX_REQUEST, __opus_check_int_ptr(x) |
|
||||
/** Configures the depth of signal being encoded.
|
|
||||
* |
|
||||
* This is a hint which helps the encoder identify silence and near-silence. |
|
||||
* It represents the number of significant bits of linear intensity below |
|
||||
* which the signal contains ignorable quantization or other noise. |
|
||||
* |
|
||||
* For example, OPUS_SET_LSB_DEPTH(14) would be an appropriate setting |
|
||||
* for G.711 u-law input. OPUS_SET_LSB_DEPTH(16) would be appropriate |
|
||||
* for 16-bit linear pcm input with opus_encode_float(). |
|
||||
* |
|
||||
* When using opus_encode() instead of opus_encode_float(), or when libopus |
|
||||
* is compiled for fixed-point, the encoder uses the minimum of the value |
|
||||
* set here and the value 16. |
|
||||
* |
|
||||
* @see OPUS_GET_LSB_DEPTH |
|
||||
* @param[in] x <tt>opus_int32</tt>: Input precision in bits, between 8 and 24 |
|
||||
* (default: 24). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_LSB_DEPTH(x) OPUS_SET_LSB_DEPTH_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured signal depth.
|
|
||||
* @see OPUS_SET_LSB_DEPTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Input precision in bits, between 8 and |
|
||||
* 24 (default: 24). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LSB_DEPTH(x) OPUS_GET_LSB_DEPTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Configures the encoder's use of variable duration frames.
|
|
||||
* When variable duration is enabled, the encoder is free to use a shorter frame |
|
||||
* size than the one requested in the opus_encode*() call. |
|
||||
* It is then the user's responsibility |
|
||||
* to verify how much audio was encoded by checking the ToC byte of the encoded |
|
||||
* packet. The part of the audio that was not encoded needs to be resent to the |
|
||||
* encoder for the next call. Do not use this option unless you <b>really</b> |
|
||||
* know what you are doing. |
|
||||
* @see OPUS_GET_EXPERT_FRAME_DURATION |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_EXPERT_FRAME_DURATION(x) OPUS_SET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured use of variable duration frames.
|
|
||||
* @see OPUS_SET_EXPERT_FRAME_DURATION |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>OPUS_FRAMESIZE_ARG</dt><dd>Select frame size from the argument (default).</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_2_5_MS</dt><dd>Use 2.5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_5_MS</dt><dd>Use 5 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_10_MS</dt><dd>Use 10 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_20_MS</dt><dd>Use 20 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_40_MS</dt><dd>Use 40 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_60_MS</dt><dd>Use 60 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_80_MS</dt><dd>Use 80 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_100_MS</dt><dd>Use 100 ms frames.</dd> |
|
||||
* <dt>OPUS_FRAMESIZE_120_MS</dt><dd>Use 120 ms frames.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_EXPERT_FRAME_DURATION(x) OPUS_GET_EXPERT_FRAME_DURATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** If set to 1, disables almost all use of prediction, making frames almost
|
|
||||
* completely independent. This reduces quality. |
|
||||
* @see OPUS_GET_PREDICTION_DISABLED |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Enable prediction (default).</dd> |
|
||||
* <dt>1</dt><dd>Disable prediction.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PREDICTION_DISABLED(x) OPUS_SET_PREDICTION_DISABLED_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured prediction status.
|
|
||||
* @see OPUS_SET_PREDICTION_DISABLED |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Prediction enabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Prediction disabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PREDICTION_DISABLED(x) OPUS_GET_PREDICTION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_genericctls Generic CTLs
|
|
||||
* |
|
||||
* These macros are used with the \c opus_decoder_ctl and |
|
||||
* \c opus_encoder_ctl calls to generate a particular |
|
||||
* request. |
|
||||
* |
|
||||
* When called on an \c OpusDecoder they apply to that |
|
||||
* particular decoder instance. When called on an |
|
||||
* \c OpusEncoder they apply to the corresponding setting |
|
||||
* on that encoder instance, if present. |
|
||||
* |
|
||||
* Some usage examples: |
|
||||
* |
|
||||
* @code |
|
||||
* int ret; |
|
||||
* opus_int32 pitch; |
|
||||
* ret = opus_decoder_ctl(dec_ctx, OPUS_GET_PITCH(&pitch)); |
|
||||
* if (ret == OPUS_OK) return ret; |
|
||||
* |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_RESET_STATE); |
|
||||
* opus_decoder_ctl(dec_ctx, OPUS_RESET_STATE); |
|
||||
* |
|
||||
* opus_int32 enc_bw, dec_bw; |
|
||||
* opus_encoder_ctl(enc_ctx, OPUS_GET_BANDWIDTH(&enc_bw)); |
|
||||
* opus_decoder_ctl(dec_ctx, OPUS_GET_BANDWIDTH(&dec_bw)); |
|
||||
* if (enc_bw != dec_bw) { |
|
||||
* printf("packet bandwidth mismatch!\n"); |
|
||||
* } |
|
||||
* @endcode |
|
||||
* |
|
||||
* @see opus_encoder, opus_decoder_ctl, opus_encoder_ctl, opus_decoderctls, opus_encoderctls |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Resets the codec state to be equivalent to a freshly initialized state.
|
|
||||
* This should be called when switching streams in order to prevent |
|
||||
* the back to back decoding from giving different results from |
|
||||
* one at a time decoding. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_RESET_STATE 4028 |
|
||||
|
|
||||
/** Gets the final state of the codec's entropy coder.
|
|
||||
* This is used for testing purposes, |
|
||||
* The encoder and decoder state should be identical after coding a payload |
|
||||
* (assuming no data corruption or software bugs) |
|
||||
* |
|
||||
* @param[out] x <tt>opus_uint32 *</tt>: Entropy coder state |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_FINAL_RANGE(x) OPUS_GET_FINAL_RANGE_REQUEST, __opus_check_uint_ptr(x) |
|
||||
|
|
||||
/** Gets the encoder's configured bandpass or the decoder's last bandpass.
|
|
||||
* @see OPUS_SET_BANDWIDTH |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_AUTO</dt> <dd>(default)</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_NARROWBAND</dt> <dd>4 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_MEDIUMBAND</dt> <dd>6 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_WIDEBAND</dt> <dd>8 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_SUPERWIDEBAND</dt><dd>12 kHz passband</dd> |
|
||||
* <dt>#OPUS_BANDWIDTH_FULLBAND</dt> <dd>20 kHz passband</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_BANDWIDTH(x) OPUS_GET_BANDWIDTH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the sampling rate the encoder or decoder was initialized with.
|
|
||||
* This simply returns the <code>Fs</code> value passed to opus_encoder_init() |
|
||||
* or opus_decoder_init(). |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Sampling rate of encoder or decoder. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_GET_SAMPLE_RATE(x) OPUS_GET_SAMPLE_RATE_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** If set to 1, disables the use of phase inversion for intensity stereo,
|
|
||||
* improving the quality of mono downmixes, but slightly reducing normal |
|
||||
* stereo quality. Disabling phase inversion in the decoder does not comply |
|
||||
* with RFC 6716, although it does not cause any interoperability issue and |
|
||||
* is expected to become part of the Opus standard once RFC 6716 is updated |
|
||||
* by draft-ietf-codec-opus-update. |
|
||||
* @see OPUS_GET_PHASE_INVERSION_DISABLED |
|
||||
* @param[in] x <tt>opus_int32</tt>: Allowed values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Enable phase inversion (default).</dd> |
|
||||
* <dt>1</dt><dd>Disable phase inversion.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_PHASE_INVERSION_DISABLED(x) OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the encoder's configured phase inversion status.
|
|
||||
* @see OPUS_SET_PHASE_INVERSION_DISABLED |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>Stereo phase inversion enabled (default).</dd> |
|
||||
* <dt>1</dt><dd>Stereo phase inversion disabled.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PHASE_INVERSION_DISABLED(x) OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST, __opus_check_int_ptr(x) |
|
||||
/** Gets the DTX state of the encoder.
|
|
||||
* Returns whether the last encoded frame was either a comfort noise update |
|
||||
* during DTX or not encoded because of DTX. |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values: |
|
||||
* <dl> |
|
||||
* <dt>0</dt><dd>The encoder is not in DTX.</dd> |
|
||||
* <dt>1</dt><dd>The encoder is in DTX.</dd> |
|
||||
* </dl> |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_IN_DTX(x) OPUS_GET_IN_DTX_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_decoderctls Decoder related CTLs
|
|
||||
* @see opus_genericctls, opus_encoderctls, opus_decoder |
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Configures decoder gain adjustment.
|
|
||||
* Scales the decoded output by a factor specified in Q8 dB units. |
|
||||
* This has a maximum range of -32768 to 32767 inclusive, and returns |
|
||||
* OPUS_BAD_ARG otherwise. The default is zero indicating no adjustment. |
|
||||
* This setting survives decoder reset. |
|
||||
* |
|
||||
* gain = pow(10, x/(20.0*256)) |
|
||||
* |
|
||||
* @param[in] x <tt>opus_int32</tt>: Amount to scale PCM signal by in Q8 dB units. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_SET_GAIN(x) OPUS_SET_GAIN_REQUEST, __opus_check_int(x) |
|
||||
/** Gets the decoder's configured gain adjustment. @see OPUS_SET_GAIN
|
|
||||
* |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Amount to scale PCM signal by in Q8 dB units. |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_GAIN(x) OPUS_GET_GAIN_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the duration (in samples) of the last packet successfully decoded or concealed.
|
|
||||
* @param[out] x <tt>opus_int32 *</tt>: Number of samples (at current sampling rate). |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_LAST_PACKET_DURATION(x) OPUS_GET_LAST_PACKET_DURATION_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/** Gets the pitch of the last decoded frame, if available.
|
|
||||
* This can be used for any post-processing algorithm requiring the use of pitch, |
|
||||
* e.g. time stretching/shortening. If the last frame was not voiced, or if the |
|
||||
* pitch was not coded in the frame, then zero is returned. |
|
||||
* |
|
||||
* This CTL is only implemented for decoder instances. |
|
||||
* |
|
||||
* @param[out] x <tt>opus_int32 *</tt>: pitch period at 48 kHz (or 0 if not available) |
|
||||
* |
|
||||
* @hideinitializer */ |
|
||||
#define OPUS_GET_PITCH(x) OPUS_GET_PITCH_REQUEST, __opus_check_int_ptr(x) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_libinfo Opus library information functions
|
|
||||
* @{ |
|
||||
*/ |
|
||||
|
|
||||
/** Converts an opus error code into a human readable string.
|
|
||||
* |
|
||||
* @param[in] error <tt>int</tt>: Error number |
|
||||
* @returns Error string |
|
||||
*/ |
|
||||
OPUS_EXPORT const char *opus_strerror(int error); |
|
||||
|
|
||||
/** Gets the libopus version string.
|
|
||||
* |
|
||||
* Applications may look for the substring "-fixed" in the version string to |
|
||||
* determine whether they have a fixed-point or floating-point build at |
|
||||
* runtime. |
|
||||
* |
|
||||
* @returns Version string |
|
||||
*/ |
|
||||
OPUS_EXPORT const char *opus_get_version_string(void); |
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_DEFINES_H */ |
|
||||
@ -1,660 +0,0 @@ |
|||||
/* Copyright (c) 2011 Xiph.Org Foundation
|
|
||||
Written by Jean-Marc Valin */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
|
|
||||
/**
|
|
||||
* @file opus_multistream.h |
|
||||
* @brief Opus reference implementation multistream API |
|
||||
*/ |
|
||||
|
|
||||
#ifndef OPUS_MULTISTREAM_H |
|
||||
#define OPUS_MULTISTREAM_H |
|
||||
|
|
||||
#include "opus.h" |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
extern "C" { |
|
||||
#endif |
|
||||
|
|
||||
/** @cond OPUS_INTERNAL_DOC */ |
|
||||
|
|
||||
/** Macros to trigger compilation errors when the wrong types are provided to a
|
|
||||
* CTL. */ |
|
||||
/**@{*/ |
|
||||
#define __opus_check_encstate_ptr(ptr) ((ptr) + ((ptr) - (OpusEncoder**)(ptr))) |
|
||||
#define __opus_check_decstate_ptr(ptr) ((ptr) + ((ptr) - (OpusDecoder**)(ptr))) |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** These are the actual encoder and decoder CTL ID numbers.
|
|
||||
* They should not be used directly by applications. |
|
||||
* In general, SETs should be even and GETs should be odd.*/ |
|
||||
/**@{*/ |
|
||||
#define OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST 5120 |
|
||||
#define OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST 5122 |
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @endcond */ |
|
||||
|
|
||||
/** @defgroup opus_multistream_ctls Multistream specific encoder and decoder CTLs
|
|
||||
* |
|
||||
* These are convenience macros that are specific to the |
|
||||
* opus_multistream_encoder_ctl() and opus_multistream_decoder_ctl() |
|
||||
* interface. |
|
||||
* The CTLs from @ref opus_genericctls, @ref opus_encoderctls, and |
|
||||
* @ref opus_decoderctls may be applied to a multistream encoder or decoder as |
|
||||
* well. |
|
||||
* In addition, you may retrieve the encoder or decoder state for an specific |
|
||||
* stream via #OPUS_MULTISTREAM_GET_ENCODER_STATE or |
|
||||
* #OPUS_MULTISTREAM_GET_DECODER_STATE and apply CTLs to it individually. |
|
||||
*/ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the encoder state for an individual stream of a multistream encoder.
|
|
||||
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose encoder you |
|
||||
* wish to retrieve. |
|
||||
* This must be non-negative and less than |
|
||||
* the <code>streams</code> parameter used |
|
||||
* to initialize the encoder. |
|
||||
* @param[out] y <tt>OpusEncoder**</tt>: Returns a pointer to the given |
|
||||
* encoder state. |
|
||||
* @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_MULTISTREAM_GET_ENCODER_STATE(x,y) OPUS_MULTISTREAM_GET_ENCODER_STATE_REQUEST, __opus_check_int(x), __opus_check_encstate_ptr(y) |
|
||||
|
|
||||
/** Gets the decoder state for an individual stream of a multistream decoder.
|
|
||||
* @param[in] x <tt>opus_int32</tt>: The index of the stream whose decoder you |
|
||||
* wish to retrieve. |
|
||||
* This must be non-negative and less than |
|
||||
* the <code>streams</code> parameter used |
|
||||
* to initialize the decoder. |
|
||||
* @param[out] y <tt>OpusDecoder**</tt>: Returns a pointer to the given |
|
||||
* decoder state. |
|
||||
* @retval OPUS_BAD_ARG The index of the requested stream was out of range. |
|
||||
* @hideinitializer |
|
||||
*/ |
|
||||
#define OPUS_MULTISTREAM_GET_DECODER_STATE(x,y) OPUS_MULTISTREAM_GET_DECODER_STATE_REQUEST, __opus_check_int(x), __opus_check_decstate_ptr(y) |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/** @defgroup opus_multistream Opus Multistream API
|
|
||||
* @{ |
|
||||
* |
|
||||
* The multistream API allows individual Opus streams to be combined into a |
|
||||
* single packet, enabling support for up to 255 channels. Unlike an |
|
||||
* elementary Opus stream, the encoder and decoder must negotiate the channel |
|
||||
* configuration before the decoder can successfully interpret the data in the |
|
||||
* packets produced by the encoder. Some basic information, such as packet |
|
||||
* duration, can be computed without any special negotiation. |
|
||||
* |
|
||||
* The format for multistream Opus packets is defined in |
|
||||
* <a href="https://tools.ietf.org/html/rfc7845">RFC 7845</a> |
|
||||
* and is based on the self-delimited Opus framing described in Appendix B of |
|
||||
* <a href="https://tools.ietf.org/html/rfc6716">RFC 6716</a>. |
|
||||
* Normal Opus packets are just a degenerate case of multistream Opus packets, |
|
||||
* and can be encoded or decoded with the multistream API by setting |
|
||||
* <code>streams</code> to <code>1</code> when initializing the encoder or |
|
||||
* decoder. |
|
||||
* |
|
||||
* Multistream Opus streams can contain up to 255 elementary Opus streams. |
|
||||
* These may be either "uncoupled" or "coupled", indicating that the decoder |
|
||||
* is configured to decode them to either 1 or 2 channels, respectively. |
|
||||
* The streams are ordered so that all coupled streams appear at the |
|
||||
* beginning. |
|
||||
* |
|
||||
* A <code>mapping</code> table defines which decoded channel <code>i</code> |
|
||||
* should be used for each input/output (I/O) channel <code>j</code>. This table is |
|
||||
* typically provided as an unsigned char array. |
|
||||
* Let <code>i = mapping[j]</code> be the index for I/O channel <code>j</code>. |
|
||||
* If <code>i < 2*coupled_streams</code>, then I/O channel <code>j</code> is |
|
||||
* encoded as the left channel of stream <code>(i/2)</code> if <code>i</code> |
|
||||
* is even, or as the right channel of stream <code>(i/2)</code> if |
|
||||
* <code>i</code> is odd. Otherwise, I/O channel <code>j</code> is encoded as |
|
||||
* mono in stream <code>(i - coupled_streams)</code>, unless it has the special |
|
||||
* value 255, in which case it is omitted from the encoding entirely (the |
|
||||
* decoder will reproduce it as silence). Each value <code>i</code> must either |
|
||||
* be the special value 255 or be less than <code>streams + coupled_streams</code>. |
|
||||
* |
|
||||
* The output channels specified by the encoder |
|
||||
* should use the |
|
||||
* <a href="https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9">Vorbis |
|
||||
* channel ordering</a>. A decoder may wish to apply an additional permutation |
|
||||
* to the mapping the encoder used to achieve a different output channel |
|
||||
* order (e.g. for outputing in WAV order). |
|
||||
* |
|
||||
* Each multistream packet contains an Opus packet for each stream, and all of |
|
||||
* the Opus packets in a single multistream packet must have the same |
|
||||
* duration. Therefore the duration of a multistream packet can be extracted |
|
||||
* from the TOC sequence of the first stream, which is located at the |
|
||||
* beginning of the packet, just like an elementary Opus stream: |
|
||||
* |
|
||||
* @code |
|
||||
* int nb_samples; |
|
||||
* int nb_frames; |
|
||||
* nb_frames = opus_packet_get_nb_frames(data, len); |
|
||||
* if (nb_frames < 1) |
|
||||
* return nb_frames; |
|
||||
* nb_samples = opus_packet_get_samples_per_frame(data, 48000) * nb_frames; |
|
||||
* @endcode |
|
||||
* |
|
||||
* The general encoding and decoding process proceeds exactly the same as in |
|
||||
* the normal @ref opus_encoder and @ref opus_decoder APIs. |
|
||||
* See their documentation for an overview of how to use the corresponding |
|
||||
* multistream functions. |
|
||||
*/ |
|
||||
|
|
||||
/** Opus multistream encoder state.
|
|
||||
* This contains the complete state of a multistream Opus encoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_multistream_encoder_create |
|
||||
* @see opus_multistream_encoder_init |
|
||||
*/ |
|
||||
typedef struct OpusMSEncoder OpusMSEncoder; |
|
||||
|
|
||||
/** Opus multistream decoder state.
|
|
||||
* This contains the complete state of a multistream Opus decoder. |
|
||||
* It is position independent and can be freely copied. |
|
||||
* @see opus_multistream_decoder_create |
|
||||
* @see opus_multistream_decoder_init |
|
||||
*/ |
|
||||
typedef struct OpusMSDecoder OpusMSDecoder; |
|
||||
|
|
||||
/**\name Multistream encoder functions */ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the size of an OpusMSEncoder structure.
|
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @returns The size in bytes on success, or a negative error code |
|
||||
* (see @ref opus_errorcodes) on error. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_encoder_get_size( |
|
||||
int streams, |
|
||||
int coupled_streams |
|
||||
); |
|
||||
|
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_surround_encoder_get_size( |
|
||||
int channels, |
|
||||
int mapping_family |
|
||||
); |
|
||||
|
|
||||
|
|
||||
/** Allocates and initializes a multistream encoder state.
|
|
||||
* Call opus_multistream_encoder_destroy() to release |
|
||||
* this object when finished. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels in the input signal. |
|
||||
* This must be at most 255. |
|
||||
* It may be greater than the number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than the number of channels. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than the number of input channels. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* encoded channels to input channels, as described in |
|
||||
* @ref opus_multistream. As an extra constraint, the |
|
||||
* multistream encoder does not allow encoding coupled |
|
||||
* streams for which one channel is unused since this |
|
||||
* is never a good idea. |
|
||||
* @param application <tt>int</tt>: The target encoder application. |
|
||||
* This must be one of the following: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
|
||||
* code (see @ref opus_errorcodes) on |
|
||||
* failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int application, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSEncoder *opus_multistream_surround_encoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int mapping_family, |
|
||||
int *streams, |
|
||||
int *coupled_streams, |
|
||||
unsigned char *mapping, |
|
||||
int application, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(4) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
/** Initialize a previously allocated multistream encoder state.
|
|
||||
* The memory pointed to by \a st must be at least the size returned by |
|
||||
* opus_multistream_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of |
|
||||
* malloc. |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @see opus_multistream_encoder_create |
|
||||
* @see opus_multistream_encoder_get_size |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate of the input signal (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels in the input signal. |
|
||||
* This must be at most 255. |
|
||||
* It may be greater than the number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams to encode from the |
|
||||
* input. |
|
||||
* This must be no more than the number of channels. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of coupled (2 channel) streams |
|
||||
* to encode. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* encoded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than the number of input channels. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* encoded channels to input channels, as described in |
|
||||
* @ref opus_multistream. As an extra constraint, the |
|
||||
* multistream encoder does not allow encoding coupled |
|
||||
* streams for which one channel is unused since this |
|
||||
* is never a good idea. |
|
||||
* @param application <tt>int</tt>: The target encoder application. |
|
||||
* This must be one of the following: |
|
||||
* <dl> |
|
||||
* <dt>#OPUS_APPLICATION_VOIP</dt> |
|
||||
* <dd>Process signal for improved speech intelligibility.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_AUDIO</dt> |
|
||||
* <dd>Favor faithfulness to the original input.</dd> |
|
||||
* <dt>#OPUS_APPLICATION_RESTRICTED_LOWDELAY</dt> |
|
||||
* <dd>Configure the minimum possible coding delay by disabling certain modes |
|
||||
* of operation.</dd> |
|
||||
* </dl> |
|
||||
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
|
||||
* on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_encoder_init( |
|
||||
OpusMSEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
OPUS_EXPORT int opus_multistream_surround_encoder_init( |
|
||||
OpusMSEncoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int mapping_family, |
|
||||
int *streams, |
|
||||
int *coupled_streams, |
|
||||
unsigned char *mapping, |
|
||||
int application |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(5) OPUS_ARG_NONNULL(6) OPUS_ARG_NONNULL(7); |
|
||||
|
|
||||
/** Encodes a multistream Opus frame.
|
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param[in] pcm <tt>const opus_int16*</tt>: The input signal as interleaved |
|
||||
* samples. |
|
||||
* This must contain |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: Number of samples per channel in the input |
|
||||
* signal. |
|
||||
* This must be an Opus frame size for the |
|
||||
* encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted values |
|
||||
* are 120, 240, 480, 960, 1920, and 2880. |
|
||||
* Passing in a duration of less than 10 ms |
|
||||
* (480 samples at 48 kHz) will prevent the |
|
||||
* encoder from using the LPC or hybrid modes. |
|
||||
* @param[out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode( |
|
||||
OpusMSEncoder *st, |
|
||||
const opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Encodes a multistream Opus frame from floating point input.
|
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param[in] pcm <tt>const float*</tt>: The input signal as interleaved |
|
||||
* samples with a normal range of |
|
||||
* +/-1.0. |
|
||||
* Samples with a range beyond +/-1.0 |
|
||||
* are supported but will be clipped by |
|
||||
* decoders using the integer API and |
|
||||
* should only be used if it is known |
|
||||
* that the far end supports extended |
|
||||
* dynamic range. |
|
||||
* This must contain |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: Number of samples per channel in the input |
|
||||
* signal. |
|
||||
* This must be an Opus frame size for the |
|
||||
* encoder's sampling rate. |
|
||||
* For example, at 48 kHz the permitted values |
|
||||
* are 120, 240, 480, 960, 1920, and 2880. |
|
||||
* Passing in a duration of less than 10 ms |
|
||||
* (480 samples at 48 kHz) will prevent the |
|
||||
* encoder from using the LPC or hybrid modes. |
|
||||
* @param[out] data <tt>unsigned char*</tt>: Output payload. |
|
||||
* This must contain storage for at |
|
||||
* least \a max_data_bytes. |
|
||||
* @param [in] max_data_bytes <tt>opus_int32</tt>: Size of the allocated |
|
||||
* memory for the output |
|
||||
* payload. This may be |
|
||||
* used to impose an upper limit on |
|
||||
* the instant bitrate, but should |
|
||||
* not be used as the only bitrate |
|
||||
* control. Use #OPUS_SET_BITRATE to |
|
||||
* control the bitrate. |
|
||||
* @returns The length of the encoded packet (in bytes) on success or a |
|
||||
* negative error code (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_encode_float( |
|
||||
OpusMSEncoder *st, |
|
||||
const float *pcm, |
|
||||
int frame_size, |
|
||||
unsigned char *data, |
|
||||
opus_int32 max_data_bytes |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(2) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Frees an <code>OpusMSEncoder</code> allocated by
|
|
||||
* opus_multistream_encoder_create(). |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_multistream_encoder_destroy(OpusMSEncoder *st); |
|
||||
|
|
||||
/** Perform a CTL function on a multistream Opus encoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated by a |
|
||||
* convenience macro. |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls, |
|
||||
* @ref opus_encoderctls, or @ref opus_multistream_ctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_encoderctls |
|
||||
* @see opus_multistream_ctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_encoder_ctl(OpusMSEncoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/**\name Multistream decoder functions */ |
|
||||
/**@{*/ |
|
||||
|
|
||||
/** Gets the size of an <code>OpusMSDecoder</code> structure.
|
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @returns The size in bytes on success, or a negative error code |
|
||||
* (see @ref opus_errorcodes) on error. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT opus_int32 opus_multistream_decoder_get_size( |
|
||||
int streams, |
|
||||
int coupled_streams |
|
||||
); |
|
||||
|
|
||||
/** Allocates and initializes a multistream decoder state.
|
|
||||
* Call opus_multistream_decoder_destroy() to release |
|
||||
* this object when finished. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels to output. |
|
||||
* This must be at most 255. |
|
||||
* It may be different from the number of coded |
|
||||
* channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* coded channels to output channels, as described in |
|
||||
* @ref opus_multistream. |
|
||||
* @param[out] error <tt>int *</tt>: Returns #OPUS_OK on success, or an error |
|
||||
* code (see @ref opus_errorcodes) on |
|
||||
* failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusMSDecoder *opus_multistream_decoder_create( |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping, |
|
||||
int *error |
|
||||
) OPUS_ARG_NONNULL(5); |
|
||||
|
|
||||
/** Intialize a previously allocated decoder state object.
|
|
||||
* The memory pointed to by \a st must be at least the size returned by |
|
||||
* opus_multistream_encoder_get_size(). |
|
||||
* This is intended for applications which use their own allocator instead of |
|
||||
* malloc. |
|
||||
* To reset a previously initialized state, use the #OPUS_RESET_STATE CTL. |
|
||||
* @see opus_multistream_decoder_create |
|
||||
* @see opus_multistream_deocder_get_size |
|
||||
* @param st <tt>OpusMSEncoder*</tt>: Multistream encoder state to initialize. |
|
||||
* @param Fs <tt>opus_int32</tt>: Sampling rate to decode at (in Hz). |
|
||||
* This must be one of 8000, 12000, 16000, |
|
||||
* 24000, or 48000. |
|
||||
* @param channels <tt>int</tt>: Number of channels to output. |
|
||||
* This must be at most 255. |
|
||||
* It may be different from the number of coded |
|
||||
* channels (<code>streams + |
|
||||
* coupled_streams</code>). |
|
||||
* @param streams <tt>int</tt>: The total number of streams coded in the |
|
||||
* input. |
|
||||
* This must be no more than 255. |
|
||||
* @param coupled_streams <tt>int</tt>: Number of streams to decode as coupled |
|
||||
* (2 channel) streams. |
|
||||
* This must be no larger than the total |
|
||||
* number of streams. |
|
||||
* Additionally, The total number of |
|
||||
* coded channels (<code>streams + |
|
||||
* coupled_streams</code>) must be no |
|
||||
* more than 255. |
|
||||
* @param[in] mapping <code>const unsigned char[channels]</code>: Mapping from |
|
||||
* coded channels to output channels, as described in |
|
||||
* @ref opus_multistream. |
|
||||
* @returns #OPUS_OK on success, or an error code (see @ref opus_errorcodes) |
|
||||
* on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_decoder_init( |
|
||||
OpusMSDecoder *st, |
|
||||
opus_int32 Fs, |
|
||||
int channels, |
|
||||
int streams, |
|
||||
int coupled_streams, |
|
||||
const unsigned char *mapping |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(6); |
|
||||
|
|
||||
/** Decode a multistream Opus packet.
|
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: Input payload. |
|
||||
* Use a <code>NULL</code> |
|
||||
* pointer to indicate packet |
|
||||
* loss. |
|
||||
* @param len <tt>opus_int32</tt>: Number of bytes in payload. |
|
||||
* @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
|
||||
* samples. |
|
||||
* This must contain room for |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: The number of samples per channel of |
|
||||
* available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration |
|
||||
* (120 ms; 5760 for 48kHz), this function will not be capable |
|
||||
* of decoding some packets. In the case of PLC (data==NULL) |
|
||||
* or FEC (decode_fec=1), then frame_size needs to be exactly |
|
||||
* the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the |
|
||||
* next incoming packet. For the PLC and FEC cases, frame_size |
|
||||
* <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
|
||||
* forward error correction data be decoded. |
|
||||
* If no such data is available, the frame is |
|
||||
* decoded as if it were lost. |
|
||||
* @returns Number of samples decoded on success or a negative error code |
|
||||
* (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode( |
|
||||
OpusMSDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
opus_int16 *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Decode a multistream Opus packet with floating point output.
|
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param[in] data <tt>const unsigned char*</tt>: Input payload. |
|
||||
* Use a <code>NULL</code> |
|
||||
* pointer to indicate packet |
|
||||
* loss. |
|
||||
* @param len <tt>opus_int32</tt>: Number of bytes in payload. |
|
||||
* @param[out] pcm <tt>opus_int16*</tt>: Output signal, with interleaved |
|
||||
* samples. |
|
||||
* This must contain room for |
|
||||
* <code>frame_size*channels</code> |
|
||||
* samples. |
|
||||
* @param frame_size <tt>int</tt>: The number of samples per channel of |
|
||||
* available space in \a pcm. |
|
||||
* If this is less than the maximum packet duration |
|
||||
* (120 ms; 5760 for 48kHz), this function will not be capable |
|
||||
* of decoding some packets. In the case of PLC (data==NULL) |
|
||||
* or FEC (decode_fec=1), then frame_size needs to be exactly |
|
||||
* the duration of audio that is missing, otherwise the |
|
||||
* decoder will not be in the optimal state to decode the |
|
||||
* next incoming packet. For the PLC and FEC cases, frame_size |
|
||||
* <b>must</b> be a multiple of 2.5 ms. |
|
||||
* @param decode_fec <tt>int</tt>: Flag (0 or 1) to request that any in-band |
|
||||
* forward error correction data be decoded. |
|
||||
* If no such data is available, the frame is |
|
||||
* decoded as if it were lost. |
|
||||
* @returns Number of samples decoded on success or a negative error code |
|
||||
* (see @ref opus_errorcodes) on failure. |
|
||||
*/ |
|
||||
OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_multistream_decode_float( |
|
||||
OpusMSDecoder *st, |
|
||||
const unsigned char *data, |
|
||||
opus_int32 len, |
|
||||
float *pcm, |
|
||||
int frame_size, |
|
||||
int decode_fec |
|
||||
) OPUS_ARG_NONNULL(1) OPUS_ARG_NONNULL(4); |
|
||||
|
|
||||
/** Perform a CTL function on a multistream Opus decoder.
|
|
||||
* |
|
||||
* Generally the request and subsequent arguments are generated by a |
|
||||
* convenience macro. |
|
||||
* @param st <tt>OpusMSDecoder*</tt>: Multistream decoder state. |
|
||||
* @param request This and all remaining parameters should be replaced by one |
|
||||
* of the convenience macros in @ref opus_genericctls, |
|
||||
* @ref opus_decoderctls, or @ref opus_multistream_ctls. |
|
||||
* @see opus_genericctls |
|
||||
* @see opus_decoderctls |
|
||||
* @see opus_multistream_ctls |
|
||||
*/ |
|
||||
OPUS_EXPORT int opus_multistream_decoder_ctl(OpusMSDecoder *st, int request, ...) OPUS_ARG_NONNULL(1); |
|
||||
|
|
||||
/** Frees an <code>OpusMSDecoder</code> allocated by
|
|
||||
* opus_multistream_decoder_create(). |
|
||||
* @param st <tt>OpusMSDecoder</tt>: Multistream decoder state to be freed. |
|
||||
*/ |
|
||||
OPUS_EXPORT void opus_multistream_decoder_destroy(OpusMSDecoder *st); |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
/**@}*/ |
|
||||
|
|
||||
#ifdef __cplusplus |
|
||||
} |
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_MULTISTREAM_H */ |
|
||||
@ -1,36 +0,0 @@ |
|||||
//
|
|
||||
// opus_swift.h
|
|
||||
// opus-swift
|
|
||||
//
|
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology
|
|
||||
//
|
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
|
||||
// in the Software without restriction, including without limitation the rights
|
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
|
||||
// furnished to do so, subject to the following conditions:
|
|
||||
//
|
|
||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||
// copies or substantial portions of the Software.
|
|
||||
//
|
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||
// SOFTWARE.
|
|
||||
//
|
|
||||
|
|
||||
#include <TargetConditionals.h> |
|
||||
|
|
||||
#if TARGET_OS_IPHONE |
|
||||
@import UIKit; |
|
||||
#else |
|
||||
@import AppKit; |
|
||||
#endif |
|
||||
|
|
||||
#include "opus.h" |
|
||||
#include "opus_multistream.h" |
|
||||
|
|
||||
@ -1,166 +0,0 @@ |
|||||
/* (C) COPYRIGHT 1994-2002 Xiph.Org Foundation */ |
|
||||
/* Modified by Jean-Marc Valin */ |
|
||||
/*
|
|
||||
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. |
|
||||
*/ |
|
||||
/* opus_types.h based on ogg_types.h from libogg */ |
|
||||
|
|
||||
/**
|
|
||||
@file opus_types.h |
|
||||
@brief Opus reference implementation types |
|
||||
*/ |
|
||||
#ifndef OPUS_TYPES_H |
|
||||
#define OPUS_TYPES_H |
|
||||
|
|
||||
#define opus_int int /* used for counters etc; at least 16 bits */ |
|
||||
#define opus_int64 long long |
|
||||
#define opus_int8 signed char |
|
||||
|
|
||||
#define opus_uint unsigned int /* used for counters etc; at least 16 bits */ |
|
||||
#define opus_uint64 unsigned long long |
|
||||
#define opus_uint8 unsigned char |
|
||||
|
|
||||
/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ |
|
||||
#if (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) |
|
||||
#include <stdint.h> |
|
||||
# undef opus_int64 |
|
||||
# undef opus_int8 |
|
||||
# undef opus_uint64 |
|
||||
# undef opus_uint8 |
|
||||
typedef int8_t opus_int8; |
|
||||
typedef uint8_t opus_uint8; |
|
||||
typedef int16_t opus_int16; |
|
||||
typedef uint16_t opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef uint32_t opus_uint32; |
|
||||
typedef int64_t opus_int64; |
|
||||
typedef uint64_t opus_uint64; |
|
||||
#elif defined(_WIN32) |
|
||||
|
|
||||
# if defined(__CYGWIN__) |
|
||||
# include <_G_config.h> |
|
||||
typedef _G_int32_t opus_int32; |
|
||||
typedef _G_uint32_t opus_uint32; |
|
||||
typedef _G_int16 opus_int16; |
|
||||
typedef _G_uint16 opus_uint16; |
|
||||
# elif defined(__MINGW32__) |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
# elif defined(__MWERKS__) |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
# else |
|
||||
/* MSVC/Borland */ |
|
||||
typedef __int32 opus_int32; |
|
||||
typedef unsigned __int32 opus_uint32; |
|
||||
typedef __int16 opus_int16; |
|
||||
typedef unsigned __int16 opus_uint16; |
|
||||
# endif |
|
||||
|
|
||||
#elif defined(__MACOS__) |
|
||||
|
|
||||
# include <sys/types.h> |
|
||||
typedef SInt16 opus_int16; |
|
||||
typedef UInt16 opus_uint16; |
|
||||
typedef SInt32 opus_int32; |
|
||||
typedef UInt32 opus_uint32; |
|
||||
|
|
||||
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ |
|
||||
|
|
||||
# include <sys/types.h> |
|
||||
typedef int16_t opus_int16; |
|
||||
typedef u_int16_t opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef u_int32_t opus_uint32; |
|
||||
|
|
||||
#elif defined(__BEOS__) |
|
||||
|
|
||||
/* Be */ |
|
||||
# include <inttypes.h> |
|
||||
typedef int16 opus_int16; |
|
||||
typedef u_int16 opus_uint16; |
|
||||
typedef int32_t opus_int32; |
|
||||
typedef u_int32_t opus_uint32; |
|
||||
|
|
||||
#elif defined (__EMX__) |
|
||||
|
|
||||
/* OS/2 GCC */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined (DJGPP) |
|
||||
|
|
||||
/* DJGPP */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined(R5900) |
|
||||
|
|
||||
/* PS2 EE */ |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned opus_uint32; |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
|
|
||||
#elif defined(__SYMBIAN32__) |
|
||||
|
|
||||
/* Symbian GCC */ |
|
||||
typedef signed short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef signed int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) |
|
||||
|
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef long opus_int32; |
|
||||
typedef unsigned long opus_uint32; |
|
||||
|
|
||||
#elif defined(CONFIG_TI_C6X) |
|
||||
|
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#else |
|
||||
|
|
||||
/* Give up, take a reasonable guess */ |
|
||||
typedef short opus_int16; |
|
||||
typedef unsigned short opus_uint16; |
|
||||
typedef int opus_int32; |
|
||||
typedef unsigned int opus_uint32; |
|
||||
|
|
||||
#endif |
|
||||
|
|
||||
#endif /* OPUS_TYPES_H */ |
|
||||
@ -1,29 +0,0 @@ |
|||||
// |
|
||||
// module.modulemap |
|
||||
// opus-swift |
|
||||
// |
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
// |
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
// of this software and associated documentation files (the "Software"), to deal |
|
||||
// in the Software without restriction, including without limitation the rights |
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
// copies of the Software, and to permit persons to whom the Software is |
|
||||
// furnished to do so, subject to the following conditions: |
|
||||
// |
|
||||
// The above copyright notice and this permission notice shall be included in all |
|
||||
// copies or substantial portions of the Software. |
|
||||
// |
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||
// SOFTWARE. |
|
||||
// |
|
||||
|
|
||||
framework module YbridOpus { |
|
||||
umbrella header "opus_swift.h" |
|
||||
export * |
|
||||
} |
|
||||
@ -1,43 +0,0 @@ |
|||||
// |
|
||||
// Config.xcconfig |
|
||||
// opus-swift |
|
||||
// |
|
||||
// Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology |
|
||||
// |
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy |
|
||||
// of this software and associated documentation files (the "Software"), to deal |
|
||||
// in the Software without restriction, including without limitation the rights |
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
||||
// copies of the Software, and to permit persons to whom the Software is |
|
||||
// furnished to do so, subject to the following conditions: |
|
||||
// |
|
||||
// The above copyright notice and this permission notice shall be included in all |
|
||||
// copies or substantial portions of the Software. |
|
||||
// |
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
||||
// SOFTWARE. |
|
||||
// |
|
||||
|
|
||||
// Configuration settings file format documentation can be found at: |
|
||||
// https://help.apple.com/xcode/#/dev745c5c974 |
|
||||
|
|
||||
// Product Version, PLEASE CHANGE HERE to affect all targets |
|
||||
MARKETING_VERSION = 0.8.0 |
|
||||
// Build number, PLEASE CHANGE HERE to affect all targets |
|
||||
CURRENT_PROJECT_VERSION = 3 |
|
||||
|
|
||||
|
|
||||
ARCHS = arm64 armv7 x86_64 x86_64h i386 |
|
||||
EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64 |
|
||||
EXCLUDED_ARCHS[sdk=macosx*] = i386 |
|
||||
SUPPORTED_PLATFORMS = iphoneos iphonesimulator macosx |
|
||||
|
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0 |
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10 |
|
||||
|
|
||||
SWIFT_VERSION = 4.0 |
|
||||
@ -1,54 +0,0 @@ |
|||||
<?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>BuildMachineOSBuild</key> |
|
||||
<string>20G80</string> |
|
||||
<key>CFBundleDevelopmentRegion</key> |
|
||||
<string>de_DE</string> |
|
||||
<key>CFBundleDisplayName</key> |
|
||||
<string>opus-swift</string> |
|
||||
<key>CFBundleExecutable</key> |
|
||||
<string>YbridOpus</string> |
|
||||
<key>CFBundleGetInfoString</key> |
|
||||
<string>libopus wrapper framework for swift</string> |
|
||||
<key>CFBundleIdentifier</key> |
|
||||
<string>io.ybrid.opus-swift</string> |
|
||||
<key>CFBundleInfoDictionaryVersion</key> |
|
||||
<string>6.0</string> |
|
||||
<key>CFBundleName</key> |
|
||||
<string>YbridOpus</string> |
|
||||
<key>CFBundlePackageType</key> |
|
||||
<string>FMWK</string> |
|
||||
<key>CFBundleShortVersionString</key> |
|
||||
<string>0.8.0</string> |
|
||||
<key>CFBundleSupportedPlatforms</key> |
|
||||
<array> |
|
||||
<string>MacOSX</string> |
|
||||
</array> |
|
||||
<key>CFBundleVersion</key> |
|
||||
<string>3</string> |
|
||||
<key>DTCompiler</key> |
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string> |
|
||||
<key>DTPlatformBuild</key> |
|
||||
<string>12E507</string> |
|
||||
<key>DTPlatformName</key> |
|
||||
<string>macosx</string> |
|
||||
<key>DTPlatformVersion</key> |
|
||||
<string>11.3</string> |
|
||||
<key>DTSDKBuild</key> |
|
||||
<string>20E214</string> |
|
||||
<key>DTSDKName</key> |
|
||||
<string>macosx11.3</string> |
|
||||
<key>DTXcode</key> |
|
||||
<string>1251</string> |
|
||||
<key>DTXcodeBuild</key> |
|
||||
<string>12E507</string> |
|
||||
<key>LSApplicationCategoryType</key> |
|
||||
<string>public.app-category.utilities</string> |
|
||||
<key>LSMinimumSystemVersion</key> |
|
||||
<string>10.10</string> |
|
||||
<key>NSHumanReadableCopyright</key> |
|
||||
<string>Copyright (c) 2021 nacamar GmbH - Ybrid®, a Hybrid Dynamic Live Audio Technology</string> |
|
||||
</dict> |
|
||||
</plist> |
|
||||
Binary file not shown.
@ -1,213 +0,0 @@ |
|||||
<?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>files</key> |
|
||||
<dict> |
|
||||
<key>Resources/Config.xcconfig</key> |
|
||||
<data> |
|
||||
+CifWGfGG+eJ+6RQiR2J6Z9++KM= |
|
||||
</data> |
|
||||
<key>Resources/Info.plist</key> |
|
||||
<data> |
|
||||
elyPlGS9VYDLNYqgLT2W+6oOOSQ= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>files2</key> |
|
||||
<dict> |
|
||||
<key>Headers/opus.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
9iqWh6KOQxloZd6AR4Nln9WTpGM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
jPzA/v85IbzDiXG+tLPzcFiknByl2mtZ+0r2OOIfjuY= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_defines.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
ZIxZY8da41baCR/GF2/AFpe6cck= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
9DvrxB739706a104pEEDAbTM24VK2EL+mF6TUjgCRAs= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_multistream.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
BckYtz94plsXQZ9RBWuV/1kcmxw= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
G/OMOd/e727v31BLWFvk1IgsAeQcWojBJJlSsQpQDvg= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_swift.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
LzT5PUj/rbYaW1AxYg5wVXuXbDA= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
tU2j9To8QDSbhu8Vz/Lv1Y6uYjEGHp0e5a6RsnGglFM= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Headers/opus_types.h</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
4eY+K/HQ77ZaFO9EKPVfVs7L2jM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
GcswHqHu28vbtQSTY94GGJO/EcIOUFple2nOb/pbEfo= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Modules/module.modulemap</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
fEkglRKWfXEJ5P20WiaR5jn2i6Y= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
spkcimiabUAXiltxFizEevGEO4anKye9lDyB981i/XU= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Resources/Config.xcconfig</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
+CifWGfGG+eJ+6RQiR2J6Z9++KM= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
yWuzbLu2XVuQ/KyJjefCQA6yUIG/ledJEQXfvayiZ78= |
|
||||
</data> |
|
||||
</dict> |
|
||||
<key>Resources/Info.plist</key> |
|
||||
<dict> |
|
||||
<key>hash</key> |
|
||||
<data> |
|
||||
elyPlGS9VYDLNYqgLT2W+6oOOSQ= |
|
||||
</data> |
|
||||
<key>hash2</key> |
|
||||
<data> |
|
||||
QwUfGwVn50kf3tdwfCf9s/BillATbyG7GAF4gW86U8o= |
|
||||
</data> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
<key>rules</key> |
|
||||
<dict> |
|
||||
<key>^Resources/</key> |
|
||||
<true/> |
|
||||
<key>^Resources/.*\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>optional</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1000</real> |
|
||||
</dict> |
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1100</real> |
|
||||
</dict> |
|
||||
<key>^Resources/Base\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>1010</real> |
|
||||
</dict> |
|
||||
<key>^version.plist$</key> |
|
||||
<true/> |
|
||||
</dict> |
|
||||
<key>rules2</key> |
|
||||
<dict> |
|
||||
<key>.*\.dSYM($|/)</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>11</real> |
|
||||
</dict> |
|
||||
<key>^(.*/)?\.DS_Store$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>2000</real> |
|
||||
</dict> |
|
||||
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key> |
|
||||
<dict> |
|
||||
<key>nested</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>10</real> |
|
||||
</dict> |
|
||||
<key>^.*</key> |
|
||||
<true/> |
|
||||
<key>^Info\.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^PkgInfo$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^Resources/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^Resources/.*\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>optional</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1000</real> |
|
||||
</dict> |
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key> |
|
||||
<dict> |
|
||||
<key>omit</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>1100</real> |
|
||||
</dict> |
|
||||
<key>^Resources/Base\.lproj/</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>1010</real> |
|
||||
</dict> |
|
||||
<key>^[^/]+$</key> |
|
||||
<dict> |
|
||||
<key>nested</key> |
|
||||
<true/> |
|
||||
<key>weight</key> |
|
||||
<real>10</real> |
|
||||
</dict> |
|
||||
<key>^embedded\.provisionprofile$</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
<key>^version\.plist$</key> |
|
||||
<dict> |
|
||||
<key>weight</key> |
|
||||
<real>20</real> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
</dict> |
|
||||
</plist> |
|
||||
@ -1 +0,0 @@ |
|||||
A |
|
||||
@ -1 +0,0 @@ |
|||||
Versions/Current/YbridOpus |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit 9261cd39d55a718bcc360fbc29515a331cad5dbb |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit 07957602bb99a5355c810187e66e6ce378a1057d |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit 92e76803ce7efc8e8903433cfd5f7f68938534ba |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit a0a57e949a8903563aba4615869310c0ebf14c03 |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit 3d8596ed08bd13520157f0355e35caed215ffbfa |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit 8f33cc5dfe81169fb167da73584b9c72c3e8bc23 |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit 9742933d2ff250212a04aed39b123bcc63a21e9c |
|
||||
@ -1 +0,0 @@ |
|||||
Subproject commit 61e4ca4b81b9e09e2ec863b00c340eb13497dac6 |
|
||||
@ -1,241 +0,0 @@ |
|||||
3448f2727d224efacea15fa4c4f01695eb13f849 not-for-merge branch '321-is-it-impossible-to-construct-this-simple-json-schema-for-a-function-definition' of https://github.com/MacPaw/OpenAI |
|
||||
fd1f90de91cc84f84d10821ecca66e4eb24dc25a not-for-merge branch '335-serversenteventsstreamparser-when-the-streamdata-length-is-1-data-is-lost' of https://github.com/MacPaw/OpenAI |
|
||||
2c397fc833f98347774976a9eab838840bc38e4e not-for-merge branch 'Krivoblotsky-patch-1' of https://github.com/MacPaw/OpenAI |
|
||||
10946a0b409139779798a75f11168b7e0dfd6a93 not-for-merge branch 'add-code-of-conduct-1' of https://github.com/MacPaw/OpenAI |
|
||||
397e009968b06a3359dd155be33c1726e33f8c59 not-for-merge branch 'add_usage_completions' of https://github.com/MacPaw/OpenAI |
|
||||
970868f66ca43766ee32d50fc174e4cf11e9c033 not-for-merge branch 'changes-to-pr329' of https://github.com/MacPaw/OpenAI |
|
||||
fcadae0f481a95b1b49d989f7e281d71eed876b9 not-for-merge branch 'chore/add-contribution-guidelines-to-readme' of https://github.com/MacPaw/OpenAI |
|
||||
ae697bfaace98c6462017851eeb370a1ba195e81 not-for-merge branch 'chore/update-codeql-actions-versions' of https://github.com/MacPaw/OpenAI |
|
||||
cd52799339e7be6dc6fccf5158a4031f2108f80c not-for-merge branch 'combine' of https://github.com/MacPaw/OpenAI |
|
||||
9685cef31ab63da81719160ef372d211aa678584 not-for-merge branch 'custom_host' of https://github.com/MacPaw/OpenAI |
|
||||
77d3aeb415f3018476d28962000c11ffdff49657 not-for-merge branch 'develop' of https://github.com/MacPaw/OpenAI |
|
||||
9d36b2110c7c60e6de40765d54a1fc7e5b521d4c not-for-merge branch 'feat/add-reasoning-effort-to-chat-query' of https://github.com/MacPaw/OpenAI |
|
||||
f01e2f78c3867d8591bdc2049e7e097ad74fcb4c not-for-merge branch 'feat/audio-speech-api-feature' of https://github.com/MacPaw/OpenAI |
|
||||
f42b26aa36e3f6734fe8c58edc457d2459b05e92 not-for-merge branch 'feature/add-codeql-security-checks' of https://github.com/MacPaw/OpenAI |
|
||||
e5d0404a2047420ec53888fdbab9aabf56addc84 not-for-merge branch 'github_action' of https://github.com/MacPaw/OpenAI |
|
||||
08eb64ee09ea99d846d797fe37ba4af779142206 not-for-merge branch 'main' of https://github.com/MacPaw/OpenAI |
|
||||
6bb14561d422c49d42b974113f86ca960d77b4ce not-for-merge branch 'streaming' of https://github.com/MacPaw/OpenAI |
|
||||
3799b2baa9fbd76921267818ddf5a20293e1c982 not-for-merge branch 'update_documentation' of https://github.com/MacPaw/OpenAI |
|
||||
1a8c368b9aed29cd784391a3d90c7ce7b0c35eaf not-for-merge branch 'whisper_api' of https://github.com/MacPaw/OpenAI |
|
||||
ef5a044ae07f12b03eaa3eb4fc6c78f09c4c706f not-for-merge 'refs/pull/1/head' of https://github.com/MacPaw/OpenAI |
|
||||
689283eca564f781738a747bcc0ddc6dc12befd5 not-for-merge 'refs/pull/102/head' of https://github.com/MacPaw/OpenAI |
|
||||
8f08006ae8391d8778a8228740d4616031f99762 not-for-merge 'refs/pull/104/head' of https://github.com/MacPaw/OpenAI |
|
||||
e1a6d0b1641b78e924fb0b94969ab758787a0b9b not-for-merge 'refs/pull/106/head' of https://github.com/MacPaw/OpenAI |
|
||||
67a03787b7bea1b3ce058eb2b047eb12315958fa not-for-merge 'refs/pull/109/head' of https://github.com/MacPaw/OpenAI |
|
||||
1a08386654a0318810cce3979da358f3ff0810fb not-for-merge 'refs/pull/115/head' of https://github.com/MacPaw/OpenAI |
|
||||
fcadae0f481a95b1b49d989f7e281d71eed876b9 not-for-merge 'refs/pull/118/head' of https://github.com/MacPaw/OpenAI |
|
||||
8fbca420a2f15e468b78e160ca87a991b2749bc6 not-for-merge 'refs/pull/12/head' of https://github.com/MacPaw/OpenAI |
|
||||
f01e2f78c3867d8591bdc2049e7e097ad74fcb4c not-for-merge 'refs/pull/120/head' of https://github.com/MacPaw/OpenAI |
|
||||
d7fb335b4e9b04334c78df33510e87e5a27c22a5 not-for-merge 'refs/pull/121/head' of https://github.com/MacPaw/OpenAI |
|
||||
dabc66e59c274ebc122c6d5f0213031fa7b4b796 not-for-merge 'refs/pull/122/head' of https://github.com/MacPaw/OpenAI |
|
||||
89040bdbe24557ef865094a69e34be3520b6dae7 not-for-merge 'refs/pull/123/head' of https://github.com/MacPaw/OpenAI |
|
||||
476c9c48240097ae62bac72147356fb87e9d2b2d not-for-merge 'refs/pull/125/head' of https://github.com/MacPaw/OpenAI |
|
||||
97e70c45f51b04ce6ebad1836f9fb6a0eec4e92a not-for-merge 'refs/pull/127/head' of https://github.com/MacPaw/OpenAI |
|
||||
9d1680ca48b99ac352d15a494b0139cbf3a1330f not-for-merge 'refs/pull/131/head' of https://github.com/MacPaw/OpenAI |
|
||||
a10d2f9e579e84aadaa4a1fc326acd9f3c848c56 not-for-merge 'refs/pull/132/head' of https://github.com/MacPaw/OpenAI |
|
||||
dca606b856efbee3466dc8398ec2e3be09efab1f not-for-merge 'refs/pull/133/head' of https://github.com/MacPaw/OpenAI |
|
||||
21e3e5882f7b4d869b743d062dec6088919adad9 not-for-merge 'refs/pull/135/head' of https://github.com/MacPaw/OpenAI |
|
||||
972718d4bed3264ec493f4c992a6b8257e4933a4 not-for-merge 'refs/pull/139/head' of https://github.com/MacPaw/OpenAI |
|
||||
a4b8f2d765a43322986dc49f76c29c5a096fcb5f not-for-merge 'refs/pull/140/head' of https://github.com/MacPaw/OpenAI |
|
||||
d50a09dc73d7774b1c42343ed171d3f806a57ca1 not-for-merge 'refs/pull/142/head' of https://github.com/MacPaw/OpenAI |
|
||||
7afc0f763cfd8561c7266981b23aca176731345a not-for-merge 'refs/pull/143/head' of https://github.com/MacPaw/OpenAI |
|
||||
867a882cfc3595854f0047dff7fa762d5cb07f48 not-for-merge 'refs/pull/146/head' of https://github.com/MacPaw/OpenAI |
|
||||
c2719668e348b82cc89176baa818c0c19ca4f588 not-for-merge 'refs/pull/149/head' of https://github.com/MacPaw/OpenAI |
|
||||
35d97bf13b60a60d875602e1bdd894fc63fc76dc not-for-merge 'refs/pull/15/head' of https://github.com/MacPaw/OpenAI |
|
||||
f0eea34e9d322054b66bde9f41b54ebec3865a83 not-for-merge 'refs/pull/150/head' of https://github.com/MacPaw/OpenAI |
|
||||
c95da8e236d389b9422453dede08bc8eaa97cbba not-for-merge 'refs/pull/151/head' of https://github.com/MacPaw/OpenAI |
|
||||
26cdd97756955561c0ca09c4f92cee07a403fd35 not-for-merge 'refs/pull/154/head' of https://github.com/MacPaw/OpenAI |
|
||||
e1b87288d03e152214e224c5b9b099a83a0b97e9 not-for-merge 'refs/pull/156/head' of https://github.com/MacPaw/OpenAI |
|
||||
8d4ba784846634fe9fd6d04c19df2c1737113b45 not-for-merge 'refs/pull/157/head' of https://github.com/MacPaw/OpenAI |
|
||||
2e57c6d958d1bfc92f395234c6f27ee0ffba2641 not-for-merge 'refs/pull/158/head' of https://github.com/MacPaw/OpenAI |
|
||||
c8d4cfb83f942882d0f9f18e8b2d16fa53acf668 not-for-merge 'refs/pull/159/head' of https://github.com/MacPaw/OpenAI |
|
||||
a58f9e43bbbeea7112eeb12b09dbf40b1e0c4cfc not-for-merge 'refs/pull/160/head' of https://github.com/MacPaw/OpenAI |
|
||||
af81a410148a1d1085843cfeba42c1a08c428c19 not-for-merge 'refs/pull/161/head' of https://github.com/MacPaw/OpenAI |
|
||||
4b69b8efac6d46c911e14d0ceecd052fe1af7729 not-for-merge 'refs/pull/162/head' of https://github.com/MacPaw/OpenAI |
|
||||
ee0885f8c4f33c0f6feec066a6de2e4c8c945fcb not-for-merge 'refs/pull/163/head' of https://github.com/MacPaw/OpenAI |
|
||||
71c142aaa8e31270535bf6bdb898b7c552034c80 not-for-merge 'refs/pull/164/head' of https://github.com/MacPaw/OpenAI |
|
||||
46314e389024cbaa0bbefc057b3b89273016f73d not-for-merge 'refs/pull/165/head' of https://github.com/MacPaw/OpenAI |
|
||||
c0edcfc7fa544434775d4626180ecb771ad3eb0e not-for-merge 'refs/pull/166/head' of https://github.com/MacPaw/OpenAI |
|
||||
2758d1a0145eab0b181e0c063feedaf724a21305 not-for-merge 'refs/pull/168/head' of https://github.com/MacPaw/OpenAI |
|
||||
ba5cd2bf24b638b2fd6e8d016976e4eb4d195f37 not-for-merge 'refs/pull/169/head' of https://github.com/MacPaw/OpenAI |
|
||||
f42b26aa36e3f6734fe8c58edc457d2459b05e92 not-for-merge 'refs/pull/17/head' of https://github.com/MacPaw/OpenAI |
|
||||
095d3fde42e5af4633467204d2a4620bb39105c0 not-for-merge 'refs/pull/172/head' of https://github.com/MacPaw/OpenAI |
|
||||
70fb77447f2a8c742d2399a40ee8c68ec667e048 not-for-merge 'refs/pull/173/head' of https://github.com/MacPaw/OpenAI |
|
||||
03a166cc68b42d39839b2707c95709fb9d546de3 not-for-merge 'refs/pull/175/head' of https://github.com/MacPaw/OpenAI |
|
||||
4a8b9b10e59860b0c91fa003993a0785d15d7ca3 not-for-merge 'refs/pull/176/head' of https://github.com/MacPaw/OpenAI |
|
||||
e7527ff5ee87baea1ff1f607c527e99aa6e123f9 not-for-merge 'refs/pull/177/head' of https://github.com/MacPaw/OpenAI |
|
||||
3cff989cc7f187f17cb0eb96efc3dd74122f5e5f not-for-merge 'refs/pull/180/head' of https://github.com/MacPaw/OpenAI |
|
||||
084c19eee0428f2a3ea850e92535fcd2ca3bf2cc not-for-merge 'refs/pull/183/head' of https://github.com/MacPaw/OpenAI |
|
||||
4524dc58978ec7a46fd2744f5e7fd1a049c45671 not-for-merge 'refs/pull/186/head' of https://github.com/MacPaw/OpenAI |
|
||||
7b7eff478e8ac8df36a6e73073ce4185b924cbaa not-for-merge 'refs/pull/188/head' of https://github.com/MacPaw/OpenAI |
|
||||
cfefcc2046cf561a4f10358782abdac9bc56ee07 not-for-merge 'refs/pull/189/head' of https://github.com/MacPaw/OpenAI |
|
||||
b818d0c3a5e713ce254a213dca6ce8f4dc16cf7d not-for-merge 'refs/pull/19/head' of https://github.com/MacPaw/OpenAI |
|
||||
f14c17a87cdc2c328970319eda6076e4ca3e426b not-for-merge 'refs/pull/190/head' of https://github.com/MacPaw/OpenAI |
|
||||
8de021d90db9eb18ab7a7a2e142eca86d446c736 not-for-merge 'refs/pull/191/head' of https://github.com/MacPaw/OpenAI |
|
||||
013226feec872c3b09c6394f262b9a3f94ccc2ac not-for-merge 'refs/pull/193/head' of https://github.com/MacPaw/OpenAI |
|
||||
7a094d1b0fa592f7f532ebd8b7043c93767d4bf4 not-for-merge 'refs/pull/196/head' of https://github.com/MacPaw/OpenAI |
|
||||
79ff47d68d0fb25a042626d3146c853aa5c2dc37 not-for-merge 'refs/pull/197/head' of https://github.com/MacPaw/OpenAI |
|
||||
0dfa3400d049f792edeb93df7df53430edc211d5 not-for-merge 'refs/pull/199/head' of https://github.com/MacPaw/OpenAI |
|
||||
e028a6f08a3f7f24527164b07aac17ec84ab8d14 not-for-merge 'refs/pull/2/head' of https://github.com/MacPaw/OpenAI |
|
||||
73955d5ed9bd6f9741aae858f997a3cac7a1549f not-for-merge 'refs/pull/204/head' of https://github.com/MacPaw/OpenAI |
|
||||
4c3a734bfa70f11a853afe5948b8c52c29cee2b4 not-for-merge 'refs/pull/206/head' of https://github.com/MacPaw/OpenAI |
|
||||
8c8d84f8348d738e9f1920e42c62659577e5c8af not-for-merge 'refs/pull/207/head' of https://github.com/MacPaw/OpenAI |
|
||||
d6459baac1236bc995d45064ae273d5f95635771 not-for-merge 'refs/pull/209/head' of https://github.com/MacPaw/OpenAI |
|
||||
61e23f7403591d3acfd2e1f8df3ce2acb7cd2b1b not-for-merge 'refs/pull/21/head' of https://github.com/MacPaw/OpenAI |
|
||||
452a149e87399b0b9d34ccb8f465cf2331c2a6f4 not-for-merge 'refs/pull/211/head' of https://github.com/MacPaw/OpenAI |
|
||||
40e730e9a3ae0870dbb512de1ac03bdf0aad2208 not-for-merge 'refs/pull/214/head' of https://github.com/MacPaw/OpenAI |
|
||||
438ee70da78288f3683411be896cb83dc30b881a not-for-merge 'refs/pull/215/head' of https://github.com/MacPaw/OpenAI |
|
||||
c784a3c39122e99084601fdd30ec4768b6c06b1e not-for-merge 'refs/pull/219/head' of https://github.com/MacPaw/OpenAI |
|
||||
53249e638e403cf6e702e810a203098891cf5704 not-for-merge 'refs/pull/222/head' of https://github.com/MacPaw/OpenAI |
|
||||
74c8929246dcef68e260fca32efdd9cf02130b8f not-for-merge 'refs/pull/225/head' of https://github.com/MacPaw/OpenAI |
|
||||
c5bbd808c6c66a7092bb30454e87b00769028ace not-for-merge 'refs/pull/226/head' of https://github.com/MacPaw/OpenAI |
|
||||
60c4af6a32af072d0d6e06ecc834e59604a4c951 not-for-merge 'refs/pull/23/head' of https://github.com/MacPaw/OpenAI |
|
||||
074608dbd753b352643a46c68a39b27994905aa5 not-for-merge 'refs/pull/235/head' of https://github.com/MacPaw/OpenAI |
|
||||
be88f6a1681f6aa7aa00538e3b677fdb442c7bfe not-for-merge 'refs/pull/236/head' of https://github.com/MacPaw/OpenAI |
|
||||
d2944b911dc094085d3dfd553d05ee2d58e59c96 not-for-merge 'refs/pull/24/head' of https://github.com/MacPaw/OpenAI |
|
||||
e34876fa6ab17a7ad0e09c50946f972a85e5e6f6 not-for-merge 'refs/pull/243/head' of https://github.com/MacPaw/OpenAI |
|
||||
e51da0e5555cbe66dd992484625ec6b3195237f7 not-for-merge 'refs/pull/245/head' of https://github.com/MacPaw/OpenAI |
|
||||
f3dd2a34ad267fc9561d4dddbcffa2be08829df8 not-for-merge 'refs/pull/246/head' of https://github.com/MacPaw/OpenAI |
|
||||
a5cd09f7e823f5cfcc36a42bcd2d841e1a2a6c2f not-for-merge 'refs/pull/247/head' of https://github.com/MacPaw/OpenAI |
|
||||
578ed123dda058e24b3d25740ec0e2193f8efcd5 not-for-merge 'refs/pull/248/head' of https://github.com/MacPaw/OpenAI |
|
||||
fa7ce713eca3727fe1522086ce83f44b5bc7d9c3 not-for-merge 'refs/pull/251/head' of https://github.com/MacPaw/OpenAI |
|
||||
ef79aa9282bf4cc3eb6d953d34f936fe680c024f not-for-merge 'refs/pull/252/head' of https://github.com/MacPaw/OpenAI |
|
||||
93873ca5820ee7e499dbff4579da04359af3e21b not-for-merge 'refs/pull/254/head' of https://github.com/MacPaw/OpenAI |
|
||||
9d36b2110c7c60e6de40765d54a1fc7e5b521d4c not-for-merge 'refs/pull/255/head' of https://github.com/MacPaw/OpenAI |
|
||||
86a0f51e1c1b43b6d1e77da3614a59e15099b7bc not-for-merge 'refs/pull/256/head' of https://github.com/MacPaw/OpenAI |
|
||||
2bbae9b6abc6736d3d654e0d3dc24ab54b1c3049 not-for-merge 'refs/pull/259/head' of https://github.com/MacPaw/OpenAI |
|
||||
c6cafa1e153001c91aa72aecc7f9b2b8a73791d2 not-for-merge 'refs/pull/262/head' of https://github.com/MacPaw/OpenAI |
|
||||
4b6cf463421c46d8d3a8c129751eade21c64d75f not-for-merge 'refs/pull/263/head' of https://github.com/MacPaw/OpenAI |
|
||||
3a97c70accd681dad4d019ac7d8a4841c3c5beeb not-for-merge 'refs/pull/264/head' of https://github.com/MacPaw/OpenAI |
|
||||
3e64d91aeb2699594fe6b743fb67eaebf724ae51 not-for-merge 'refs/pull/266/head' of https://github.com/MacPaw/OpenAI |
|
||||
309335cf695dfdc53fdfaf77e072947c1682b027 not-for-merge 'refs/pull/267/head' of https://github.com/MacPaw/OpenAI |
|
||||
9c3f7d915f3d8cd62311392d7b64298ecf922f9b not-for-merge 'refs/pull/268/head' of https://github.com/MacPaw/OpenAI |
|
||||
2908c541f11c4e79bf141db4f0f46d231d200da1 not-for-merge 'refs/pull/269/head' of https://github.com/MacPaw/OpenAI |
|
||||
315ffc8412ae82a88979622920bd1ca2b5753853 not-for-merge 'refs/pull/270/head' of https://github.com/MacPaw/OpenAI |
|
||||
a10451a15cfe4172420005761ca0dbda558e0c08 not-for-merge 'refs/pull/273/head' of https://github.com/MacPaw/OpenAI |
|
||||
ae697bfaace98c6462017851eeb370a1ba195e81 not-for-merge 'refs/pull/274/head' of https://github.com/MacPaw/OpenAI |
|
||||
b4291c2ba5c35e01d5045da3c2b9db939d3d1ebe not-for-merge 'refs/pull/275/head' of https://github.com/MacPaw/OpenAI |
|
||||
158f1db7b437c2b830b6a5afda161e7c9e262029 not-for-merge 'refs/pull/277/head' of https://github.com/MacPaw/OpenAI |
|
||||
f2581cb1a4d45f3a0968bcb5b006c489d46118e4 not-for-merge 'refs/pull/279/head' of https://github.com/MacPaw/OpenAI |
|
||||
27ffac57c01ae2c87e2ebdf34a73e1824093e2ca not-for-merge 'refs/pull/28/head' of https://github.com/MacPaw/OpenAI |
|
||||
cac9ac8f669559a9865a3f1ab48a31dc14aa5e3b not-for-merge 'refs/pull/280/head' of https://github.com/MacPaw/OpenAI |
|
||||
9bbad27aa94c6bb0ee497e584cc5406692750057 not-for-merge 'refs/pull/282/head' of https://github.com/MacPaw/OpenAI |
|
||||
473c67683787ba54d48aea6bf0006690990bb066 not-for-merge 'refs/pull/284/head' of https://github.com/MacPaw/OpenAI |
|
||||
c83d060850953a68a597e8a5ff9f7be1daf85781 not-for-merge 'refs/pull/285/head' of https://github.com/MacPaw/OpenAI |
|
||||
b941641f5affa4964c40b5f41e82219d5e7b4424 not-for-merge 'refs/pull/286/head' of https://github.com/MacPaw/OpenAI |
|
||||
344736560d0ce4201ce7ce064ccca110d02e4f9d not-for-merge 'refs/pull/287/head' of https://github.com/MacPaw/OpenAI |
|
||||
9a1a8f7c6a6d02499098b45b7bef4e300d913483 not-for-merge 'refs/pull/288/head' of https://github.com/MacPaw/OpenAI |
|
||||
3f7bdda48a7c1b19dfabb6f85bfc24bf7dbaeae2 not-for-merge 'refs/pull/289/head' of https://github.com/MacPaw/OpenAI |
|
||||
5d8ab66ec8cf4e911817eccebdcc84dd7a75fa09 not-for-merge 'refs/pull/29/head' of https://github.com/MacPaw/OpenAI |
|
||||
0de633bcb4908da9f5b42fcf0d68070664d0180f not-for-merge 'refs/pull/290/head' of https://github.com/MacPaw/OpenAI |
|
||||
5684c56ef7fa0cda9a30ccbc3112006f997b0b5d not-for-merge 'refs/pull/291/head' of https://github.com/MacPaw/OpenAI |
|
||||
a60c1e685a1949194c8102fd4e5ee182008ee4d8 not-for-merge 'refs/pull/294/head' of https://github.com/MacPaw/OpenAI |
|
||||
5970c3a5d0b19a7f2f0f63ddd8d172ef489acd71 not-for-merge 'refs/pull/295/head' of https://github.com/MacPaw/OpenAI |
|
||||
faefcdc2e068e3c940a0bc6acea3adb1f80991f6 not-for-merge 'refs/pull/297/head' of https://github.com/MacPaw/OpenAI |
|
||||
6d1d9d146e6cf81b32203f50f77342086cdcba10 not-for-merge 'refs/pull/299/head' of https://github.com/MacPaw/OpenAI |
|
||||
2c026377690d0ddf09eea5f217a7c35aebf99412 not-for-merge 'refs/pull/3/head' of https://github.com/MacPaw/OpenAI |
|
||||
76fcf13de31c0e62ed0bef5da999f3ea04dfb854 not-for-merge 'refs/pull/30/head' of https://github.com/MacPaw/OpenAI |
|
||||
ab658da2cd40610bd1bcf5472c6610a43cbcd1ed not-for-merge 'refs/pull/300/head' of https://github.com/MacPaw/OpenAI |
|
||||
85dbb568d2f509aaad3f069d5915f04f2d5ce03c not-for-merge 'refs/pull/301/head' of https://github.com/MacPaw/OpenAI |
|
||||
a9d109c7e9795aada6d0c2957c2cc0cd44a101f9 not-for-merge 'refs/pull/302/head' of https://github.com/MacPaw/OpenAI |
|
||||
bef5a5d4dcfd5cdd4e48f50789c5f719f9808176 not-for-merge 'refs/pull/303/head' of https://github.com/MacPaw/OpenAI |
|
||||
dea6d20472c218322cd5b0c2f561bf76c89be477 not-for-merge 'refs/pull/304/head' of https://github.com/MacPaw/OpenAI |
|
||||
77cf0d2b858ccf302d04702c98c03028063d1a6d not-for-merge 'refs/pull/305/head' of https://github.com/MacPaw/OpenAI |
|
||||
8812d9b5bcb31fbfdbd82699bda87a8056227a1d not-for-merge 'refs/pull/306/head' of https://github.com/MacPaw/OpenAI |
|
||||
748866784b1e1a12b54494bcbcd2cba8ee7a7c96 not-for-merge 'refs/pull/307/head' of https://github.com/MacPaw/OpenAI |
|
||||
1a8c368b9aed29cd784391a3d90c7ce7b0c35eaf not-for-merge 'refs/pull/31/head' of https://github.com/MacPaw/OpenAI |
|
||||
aad8b4c45558eebacdbfaae101012071bebf7ba3 not-for-merge 'refs/pull/310/head' of https://github.com/MacPaw/OpenAI |
|
||||
a9519b6c5dcb50c4250eca336bd7730c197e1221 not-for-merge 'refs/pull/311/head' of https://github.com/MacPaw/OpenAI |
|
||||
86d9cb0048e93b89f56a7c8711a43411e3d0df5b not-for-merge 'refs/pull/312/head' of https://github.com/MacPaw/OpenAI |
|
||||
5639ee85299faa287f2e5a485d67a1e780acfe5e not-for-merge 'refs/pull/313/head' of https://github.com/MacPaw/OpenAI |
|
||||
ff0fe4eafa1add3a52c55c5b63e680a7be4ab538 not-for-merge 'refs/pull/314/head' of https://github.com/MacPaw/OpenAI |
|
||||
e3b02de226b8c4b5a20406d97c6244131d1b922e not-for-merge 'refs/pull/316/head' of https://github.com/MacPaw/OpenAI |
|
||||
ee1eeba1b943c505d781aed13d061dac46ac4333 not-for-merge 'refs/pull/318/head' of https://github.com/MacPaw/OpenAI |
|
||||
029950f39af3d8491fdbdb43a46317c5398026ea not-for-merge 'refs/pull/319/head' of https://github.com/MacPaw/OpenAI |
|
||||
7ac440b7136498a90ed1071e532e5d04cdf2d375 not-for-merge 'refs/pull/32/head' of https://github.com/MacPaw/OpenAI |
|
||||
bc7691385b48ef8c531969f859ff50f2c28912b5 not-for-merge 'refs/pull/320/head' of https://github.com/MacPaw/OpenAI |
|
||||
7d66d8f97dcbc49dbbc65ba8752401d1dda1fac6 not-for-merge 'refs/pull/322/head' of https://github.com/MacPaw/OpenAI |
|
||||
b886b7b67bab4450d5a27b7fc82ccb0127213409 not-for-merge 'refs/pull/323/head' of https://github.com/MacPaw/OpenAI |
|
||||
62e2cd32dae2b0d3743e79310bcad19467978853 not-for-merge 'refs/pull/325/head' of https://github.com/MacPaw/OpenAI |
|
||||
3676f2536a3e76d65c33d3244dff938de6db5279 not-for-merge 'refs/pull/326/head' of https://github.com/MacPaw/OpenAI |
|
||||
7a74bc1ef76361730d8297572e52f0063cbbb797 not-for-merge 'refs/pull/328/head' of https://github.com/MacPaw/OpenAI |
|
||||
193273444417fd0c28717b15d635f78806f2e526 not-for-merge 'refs/pull/329/head' of https://github.com/MacPaw/OpenAI |
|
||||
9685cef31ab63da81719160ef372d211aa678584 not-for-merge 'refs/pull/33/head' of https://github.com/MacPaw/OpenAI |
|
||||
866f4f8c66fc6b3e225e28661e288ea3bca0ecdf not-for-merge 'refs/pull/330/head' of https://github.com/MacPaw/OpenAI |
|
||||
112eb89cabefc0e08794ee2281f890ae0e067c21 not-for-merge 'refs/pull/332/head' of https://github.com/MacPaw/OpenAI |
|
||||
1558dd59c5c8a4b053ab6751f8ed8f7fc1cfa45b not-for-merge 'refs/pull/333/head' of https://github.com/MacPaw/OpenAI |
|
||||
d232189be788ab3f14a0c364147fbdc5082f72a1 not-for-merge 'refs/pull/334/head' of https://github.com/MacPaw/OpenAI |
|
||||
fd1f90de91cc84f84d10821ecca66e4eb24dc25a not-for-merge 'refs/pull/336/head' of https://github.com/MacPaw/OpenAI |
|
||||
94ed9f1abac079dc243e87831342eb1f22cde357 not-for-merge 'refs/pull/337/head' of https://github.com/MacPaw/OpenAI |
|
||||
7037f037f9e9ee00db70e61663381d18aeba0645 not-for-merge 'refs/pull/339/head' of https://github.com/MacPaw/OpenAI |
|
||||
cd52799339e7be6dc6fccf5158a4031f2108f80c not-for-merge 'refs/pull/34/head' of https://github.com/MacPaw/OpenAI |
|
||||
896c586226e9eecd0c44cca4a4057f179a505feb not-for-merge 'refs/pull/37/head' of https://github.com/MacPaw/OpenAI |
|
||||
1a9ea32870e50f4a36b94ac8228af1a96780a861 not-for-merge 'refs/pull/38/head' of https://github.com/MacPaw/OpenAI |
|
||||
397e009968b06a3359dd155be33c1726e33f8c59 not-for-merge 'refs/pull/39/head' of https://github.com/MacPaw/OpenAI |
|
||||
f026422783be026aa45e895a2efa5563ebc3e966 not-for-merge 'refs/pull/4/head' of https://github.com/MacPaw/OpenAI |
|
||||
f117481ba48a5f740f5f9a801ebd8139d6e7a851 not-for-merge 'refs/pull/40/head' of https://github.com/MacPaw/OpenAI |
|
||||
fb2d1aae9d210e8a0f4467552920d03ad6273e1c not-for-merge 'refs/pull/42/head' of https://github.com/MacPaw/OpenAI |
|
||||
559166d6574cacd8ebce0883d6a94daeb98be5f5 not-for-merge 'refs/pull/43/head' of https://github.com/MacPaw/OpenAI |
|
||||
fa91871f9bb1ffdb9fb6ed5b5d9417f058b500a1 not-for-merge 'refs/pull/44/head' of https://github.com/MacPaw/OpenAI |
|
||||
7d26bfd098ed1e1469a369ed0652e89b8e74e94f not-for-merge 'refs/pull/47/head' of https://github.com/MacPaw/OpenAI |
|
||||
e85c47b8a7ff3b2b1037b3004d9a67b04a2b0876 not-for-merge 'refs/pull/5/head' of https://github.com/MacPaw/OpenAI |
|
||||
63c31a2d892ad23feb281429b5c1c1122f8dfb1a not-for-merge 'refs/pull/51/head' of https://github.com/MacPaw/OpenAI |
|
||||
d64b67d67141f2c58f6d6a5c8d4b363433f2b308 not-for-merge 'refs/pull/52/head' of https://github.com/MacPaw/OpenAI |
|
||||
8d7cd667255016b92f72e81bebe21517bc57e12e not-for-merge 'refs/pull/54/head' of https://github.com/MacPaw/OpenAI |
|
||||
56b795692ac0296c32dbe2c01c260b016cee1de4 not-for-merge 'refs/pull/55/head' of https://github.com/MacPaw/OpenAI |
|
||||
c25f6e77df11200d6b1106d7670d494dbb3be9ef not-for-merge 'refs/pull/56/head' of https://github.com/MacPaw/OpenAI |
|
||||
6bb14561d422c49d42b974113f86ca960d77b4ce not-for-merge 'refs/pull/57/head' of https://github.com/MacPaw/OpenAI |
|
||||
04cf5ba5d2cf46cef38592a0139d91db0fff6cdd not-for-merge 'refs/pull/59/head' of https://github.com/MacPaw/OpenAI |
|
||||
edd80f3daa58fd513ceef462ee1b2f5453364ecc not-for-merge 'refs/pull/60/head' of https://github.com/MacPaw/OpenAI |
|
||||
7e22461629f6767894a7f3a253e150c332d451dc not-for-merge 'refs/pull/62/head' of https://github.com/MacPaw/OpenAI |
|
||||
98980589f72f834760345f62829eddd55ebf2d11 not-for-merge 'refs/pull/63/head' of https://github.com/MacPaw/OpenAI |
|
||||
11a31932658779b1fb376c17e977898e29d62867 not-for-merge 'refs/pull/66/head' of https://github.com/MacPaw/OpenAI |
|
||||
1bc146e28a11fad7811814b008e82e20dcdc99c3 not-for-merge 'refs/pull/69/head' of https://github.com/MacPaw/OpenAI |
|
||||
10946a0b409139779798a75f11168b7e0dfd6a93 not-for-merge 'refs/pull/7/head' of https://github.com/MacPaw/OpenAI |
|
||||
54e2a45953b3666906750cc1caf296da3e59b0c2 not-for-merge 'refs/pull/77/head' of https://github.com/MacPaw/OpenAI |
|
||||
2620356f08bfa6ea6f5f3cc3618fc93cc71e57a6 not-for-merge 'refs/pull/78/head' of https://github.com/MacPaw/OpenAI |
|
||||
2c397fc833f98347774976a9eab838840bc38e4e not-for-merge 'refs/pull/80/head' of https://github.com/MacPaw/OpenAI |
|
||||
c3f1c96dec84042b14fac1ce11ce2942a3a88957 not-for-merge 'refs/pull/82/head' of https://github.com/MacPaw/OpenAI |
|
||||
a6e1b2fc5d759da9bbe51365d546d481a0a689d3 not-for-merge 'refs/pull/84/head' of https://github.com/MacPaw/OpenAI |
|
||||
e96abc9a90eb76af9c7e021753313c227f45c471 not-for-merge 'refs/pull/87/head' of https://github.com/MacPaw/OpenAI |
|
||||
c6533e55e312cc83eabb8558621e49f448a5de9d not-for-merge 'refs/pull/89/head' of https://github.com/MacPaw/OpenAI |
|
||||
1c803034fbb5aee6d23eb6d3260d03b599ba8275 not-for-merge 'refs/pull/92/head' of https://github.com/MacPaw/OpenAI |
|
||||
b874f2d92ac0bd4a33287aac2acf88ed42754fcb not-for-merge 'refs/pull/93/head' of https://github.com/MacPaw/OpenAI |
|
||||
56dd35ca36a0e26568a3d884e5a53296ded3f60d not-for-merge 'refs/pull/95/head' of https://github.com/MacPaw/OpenAI |
|
||||
fa54b01a37211795944c4021e20cd94fb0a92c80 not-for-merge tag '0.0.1' of https://github.com/MacPaw/OpenAI |
|
||||
59ed31bd328adc790c0943383671fc1b7b46ffcf not-for-merge tag '0.0.2' of https://github.com/MacPaw/OpenAI |
|
||||
fb6c8ca96ad6ba9864d279a32fd8159b3b4f2115 not-for-merge tag '0.0.3' of https://github.com/MacPaw/OpenAI |
|
||||
848aaaba4743413f80876a0a370383db3d45b092 not-for-merge tag '0.0.4' of https://github.com/MacPaw/OpenAI |
|
||||
9a39fc46ae2c406d55b01d77e70fdaed3eb360b9 not-for-merge tag '0.0.5' of https://github.com/MacPaw/OpenAI |
|
||||
84bf2f1f3d40446723e7d37f23d494a562d65547 not-for-merge tag '0.0.6' of https://github.com/MacPaw/OpenAI |
|
||||
c3bf1cf82e77b9cc0b2fc284d3ff5d66086c0351 not-for-merge tag '0.0.7' of https://github.com/MacPaw/OpenAI |
|
||||
1eb998b59303883ea0bb65e91d1b48c14234e3d6 not-for-merge tag '0.0.8' of https://github.com/MacPaw/OpenAI |
|
||||
3c591d975860a949b4eca2c1bc6c2a197fc469f5 not-for-merge tag '0.0.9' of https://github.com/MacPaw/OpenAI |
|
||||
b9c9a7992cbe8a5ddc8638a5e8c705d3ab90a5c0 not-for-merge tag '0.1.0' of https://github.com/MacPaw/OpenAI |
|
||||
a5384ea6c43be98aec1cff64d177f2197c30beeb not-for-merge tag '0.1.1' of https://github.com/MacPaw/OpenAI |
|
||||
652abeb7bb7d091c9d26a9ccff474faf423fa5e5 not-for-merge tag '0.1.2' of https://github.com/MacPaw/OpenAI |
|
||||
119b3933b0afae84a781be1590d9e93304a214be not-for-merge tag '0.2.0' of https://github.com/MacPaw/OpenAI |
|
||||
907b7471e348683bcfafac23e865b9240bd11ece not-for-merge tag '0.2.1' of https://github.com/MacPaw/OpenAI |
|
||||
bee39ef1fa677946ca8afa1fcafd766384b56dee not-for-merge tag '0.2.2' of https://github.com/MacPaw/OpenAI |
|
||||
310e18879ed538e28e81b90bf22845c739f0ee98 not-for-merge tag '0.2.3' of https://github.com/MacPaw/OpenAI |
|
||||
f16aa9a22382ffe780dcc63975ca30223984bffe not-for-merge tag '0.2.4' of https://github.com/MacPaw/OpenAI |
|
||||
ac5892fd0de8d283362ddc30f8e9f1a0eaba8cc0 not-for-merge tag '0.2.5' of https://github.com/MacPaw/OpenAI |
|
||||
35afc9a6ee127b8f22a85a31aec2036a987478af not-for-merge tag '0.2.6' of https://github.com/MacPaw/OpenAI |
|
||||
5861c597799016026e9c879fb28a8207e59a5b6b not-for-merge tag '0.2.7' of https://github.com/MacPaw/OpenAI |
|
||||
99593869a02555e456865dd7f742e7a5add24e06 not-for-merge tag '0.2.8' of https://github.com/MacPaw/OpenAI |
|
||||
fd13a41e987004d14f1793c570721953a2767b03 not-for-merge tag '0.2.9' of https://github.com/MacPaw/OpenAI |
|
||||
843e087929aa806adb611dbca93f9a4a7f28be04 not-for-merge tag '0.3.0' of https://github.com/MacPaw/OpenAI |
|
||||
2d8cf55525d039848f796c4d1e3d6c88a7e03f6e not-for-merge tag '0.3.1' of https://github.com/MacPaw/OpenAI |
|
||||
5f05c8f41ee1cfeb586bba0fa301240630ca2548 not-for-merge tag '0.3.2' of https://github.com/MacPaw/OpenAI |
|
||||
57059754f93f875f107e576b3a33e27a365c663e not-for-merge tag '0.3.3' of https://github.com/MacPaw/OpenAI |
|
||||
190c35534eb9ea07a7deed641e3ca46d54759271 not-for-merge tag '0.3.4' of https://github.com/MacPaw/OpenAI |
|
||||
0e8b8b1bc5e101a3c761b6519dc4df6ecddf415c not-for-merge tag '0.3.5' of https://github.com/MacPaw/OpenAI |
|
||||
e59e4923acc924db51d415e99d0a76c7d54037e0 not-for-merge tag '0.3.6' of https://github.com/MacPaw/OpenAI |
|
||||
1a7a5bae571b5ff096c8b2c1062577248214f52e not-for-merge tag '0.3.7' of https://github.com/MacPaw/OpenAI |
|
||||
58de48f0da70ec743727849245c24a22c03f1ee6 not-for-merge tag '0.3.8' of https://github.com/MacPaw/OpenAI |
|
||||
f5b55e19b5a634d1c86ca4f77e614ffd19d5fc1d not-for-merge tag '0.3.9' of https://github.com/MacPaw/OpenAI |
|
||||
0da7b834bc318f99776d71b3ff2915573cdf8c66 not-for-merge tag '0.4.0' of https://github.com/MacPaw/OpenAI |
|
||||
7eef412b26b0b2af6add548bb60f25f306b41ee2 not-for-merge tag '0.4.1' of https://github.com/MacPaw/OpenAI |
|
||||
40f3d6cdb5a2ad72369984a8e0e99a28c6e46f47 not-for-merge tag '0.4.2' of https://github.com/MacPaw/OpenAI |
|
||||
9261cd39d55a718bcc360fbc29515a331cad5dbb not-for-merge tag '0.4.3' of https://github.com/MacPaw/OpenAI |
|
||||
0df788b3ca6444274f140165d2f416942f63c481 not-for-merge tag 'feat/additional-headers' of https://github.com/MacPaw/OpenAI |
|
||||
@ -1 +0,0 @@ |
|||||
ref: refs/heads/main |
|
||||
@ -1,10 +0,0 @@ |
|||||
[core] |
|
||||
repositoryformatversion = 0 |
|
||||
filemode = true |
|
||||
bare = true |
|
||||
ignorecase = true |
|
||||
precomposeunicode = true |
|
||||
[remote "origin"] |
|
||||
url = https://github.com/MacPaw/OpenAI.git |
|
||||
fetch = +refs/*:refs/* |
|
||||
mirror = true |
|
||||
@ -1 +0,0 @@ |
|||||
Unnamed repository; edit this file 'description' to name the repository. |
|
||||
@ -1,15 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to check the commit log message taken by |
|
||||
# applypatch from an e-mail message. |
|
||||
# |
|
||||
# The hook should exit with non-zero status after issuing an |
|
||||
# appropriate message if it wants to stop the commit. The hook is |
|
||||
# allowed to edit the commit message file. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "applypatch-msg". |
|
||||
|
|
||||
. git-sh-setup |
|
||||
commitmsg="$(git rev-parse --git-path hooks/commit-msg)" |
|
||||
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} |
|
||||
: |
|
||||
@ -1,24 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to check the commit log message. |
|
||||
# Called by "git commit" with one argument, the name of the file |
|
||||
# that has the commit message. The hook should exit with non-zero |
|
||||
# status after issuing an appropriate message if it wants to stop the |
|
||||
# commit. The hook is allowed to edit the commit message file. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "commit-msg". |
|
||||
|
|
||||
# Uncomment the below to add a Signed-off-by line to the message. |
|
||||
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg |
|
||||
# hook is more suited to it. |
|
||||
# |
|
||||
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') |
|
||||
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" |
|
||||
|
|
||||
# This example catches duplicate Signed-off-by lines. |
|
||||
|
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" | |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { |
|
||||
echo >&2 Duplicate Signed-off-by lines. |
|
||||
exit 1 |
|
||||
} |
|
||||
@ -1,174 +0,0 @@ |
|||||
#!/usr/bin/perl |
|
||||
|
|
||||
use strict; |
|
||||
use warnings; |
|
||||
use IPC::Open2; |
|
||||
|
|
||||
# An example hook script to integrate Watchman |
|
||||
# (https://facebook.github.io/watchman/) with git to speed up detecting |
|
||||
# new and modified files. |
|
||||
# |
|
||||
# The hook is passed a version (currently 2) and last update token |
|
||||
# formatted as a string and outputs to stdout a new update token and |
|
||||
# all files that have been modified since the update token. Paths must |
|
||||
# be relative to the root of the working tree and separated by a single NUL. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "query-watchman" and set |
|
||||
# 'git config core.fsmonitor .git/hooks/query-watchman' |
|
||||
# |
|
||||
my ($version, $last_update_token) = @ARGV; |
|
||||
|
|
||||
# Uncomment for debugging |
|
||||
# print STDERR "$0 $version $last_update_token\n"; |
|
||||
|
|
||||
# Check the hook interface version |
|
||||
if ($version ne 2) { |
|
||||
die "Unsupported query-fsmonitor hook version '$version'.\n" . |
|
||||
"Falling back to scanning...\n"; |
|
||||
} |
|
||||
|
|
||||
my $git_work_tree = get_working_dir(); |
|
||||
|
|
||||
my $retry = 1; |
|
||||
|
|
||||
my $json_pkg; |
|
||||
eval { |
|
||||
require JSON::XS; |
|
||||
$json_pkg = "JSON::XS"; |
|
||||
1; |
|
||||
} or do { |
|
||||
require JSON::PP; |
|
||||
$json_pkg = "JSON::PP"; |
|
||||
}; |
|
||||
|
|
||||
launch_watchman(); |
|
||||
|
|
||||
sub launch_watchman { |
|
||||
my $o = watchman_query(); |
|
||||
if (is_work_tree_watched($o)) { |
|
||||
output_result($o->{clock}, @{$o->{files}}); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
sub output_result { |
|
||||
my ($clockid, @files) = @_; |
|
||||
|
|
||||
# Uncomment for debugging watchman output |
|
||||
# open (my $fh, ">", ".git/watchman-output.out"); |
|
||||
# binmode $fh, ":utf8"; |
|
||||
# print $fh "$clockid\n@files\n"; |
|
||||
# close $fh; |
|
||||
|
|
||||
binmode STDOUT, ":utf8"; |
|
||||
print $clockid; |
|
||||
print "\0"; |
|
||||
local $, = "\0"; |
|
||||
print @files; |
|
||||
} |
|
||||
|
|
||||
sub watchman_clock { |
|
||||
my $response = qx/watchman clock "$git_work_tree"/; |
|
||||
die "Failed to get clock id on '$git_work_tree'.\n" . |
|
||||
"Falling back to scanning...\n" if $? != 0; |
|
||||
|
|
||||
return $json_pkg->new->utf8->decode($response); |
|
||||
} |
|
||||
|
|
||||
sub watchman_query { |
|
||||
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') |
|
||||
or die "open2() failed: $!\n" . |
|
||||
"Falling back to scanning...\n"; |
|
||||
|
|
||||
# In the query expression below we're asking for names of files that |
|
||||
# changed since $last_update_token but not from the .git folder. |
|
||||
# |
|
||||
# To accomplish this, we're using the "since" generator to use the |
|
||||
# recency index to select candidate nodes and "fields" to limit the |
|
||||
# output to file names only. Then we're using the "expression" term to |
|
||||
# further constrain the results. |
|
||||
my $last_update_line = ""; |
|
||||
if (substr($last_update_token, 0, 1) eq "c") { |
|
||||
$last_update_token = "\"$last_update_token\""; |
|
||||
$last_update_line = qq[\n"since": $last_update_token,]; |
|
||||
} |
|
||||
my $query = <<" END"; |
|
||||
["query", "$git_work_tree", {$last_update_line |
|
||||
"fields": ["name"], |
|
||||
"expression": ["not", ["dirname", ".git"]] |
|
||||
}] |
|
||||
END |
|
||||
|
|
||||
# Uncomment for debugging the watchman query |
|
||||
# open (my $fh, ">", ".git/watchman-query.json"); |
|
||||
# print $fh $query; |
|
||||
# close $fh; |
|
||||
|
|
||||
print CHLD_IN $query; |
|
||||
close CHLD_IN; |
|
||||
my $response = do {local $/; <CHLD_OUT>}; |
|
||||
|
|
||||
# Uncomment for debugging the watch response |
|
||||
# open ($fh, ">", ".git/watchman-response.json"); |
|
||||
# print $fh $response; |
|
||||
# close $fh; |
|
||||
|
|
||||
die "Watchman: command returned no output.\n" . |
|
||||
"Falling back to scanning...\n" if $response eq ""; |
|
||||
die "Watchman: command returned invalid output: $response\n" . |
|
||||
"Falling back to scanning...\n" unless $response =~ /^\{/; |
|
||||
|
|
||||
return $json_pkg->new->utf8->decode($response); |
|
||||
} |
|
||||
|
|
||||
sub is_work_tree_watched { |
|
||||
my ($output) = @_; |
|
||||
my $error = $output->{error}; |
|
||||
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) { |
|
||||
$retry--; |
|
||||
my $response = qx/watchman watch "$git_work_tree"/; |
|
||||
die "Failed to make watchman watch '$git_work_tree'.\n" . |
|
||||
"Falling back to scanning...\n" if $? != 0; |
|
||||
$output = $json_pkg->new->utf8->decode($response); |
|
||||
$error = $output->{error}; |
|
||||
die "Watchman: $error.\n" . |
|
||||
"Falling back to scanning...\n" if $error; |
|
||||
|
|
||||
# Uncomment for debugging watchman output |
|
||||
# open (my $fh, ">", ".git/watchman-output.out"); |
|
||||
# close $fh; |
|
||||
|
|
||||
# Watchman will always return all files on the first query so |
|
||||
# return the fast "everything is dirty" flag to git and do the |
|
||||
# Watchman query just to get it over with now so we won't pay |
|
||||
# the cost in git to look up each individual file. |
|
||||
my $o = watchman_clock(); |
|
||||
$error = $output->{error}; |
|
||||
|
|
||||
die "Watchman: $error.\n" . |
|
||||
"Falling back to scanning...\n" if $error; |
|
||||
|
|
||||
output_result($o->{clock}, ("/")); |
|
||||
$last_update_token = $o->{clock}; |
|
||||
|
|
||||
eval { launch_watchman() }; |
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
die "Watchman: $error.\n" . |
|
||||
"Falling back to scanning...\n" if $error; |
|
||||
|
|
||||
return 1; |
|
||||
} |
|
||||
|
|
||||
sub get_working_dir { |
|
||||
my $working_dir; |
|
||||
if ($^O =~ 'msys' || $^O =~ 'cygwin') { |
|
||||
$working_dir = Win32::GetCwd(); |
|
||||
$working_dir =~ tr/\\/\//; |
|
||||
} else { |
|
||||
require Cwd; |
|
||||
$working_dir = Cwd::cwd(); |
|
||||
} |
|
||||
|
|
||||
return $working_dir; |
|
||||
} |
|
||||
@ -1,8 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to prepare a packed repository for use over |
|
||||
# dumb transports. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "post-update". |
|
||||
|
|
||||
exec git update-server-info |
|
||||
@ -1,14 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to verify what is about to be committed |
|
||||
# by applypatch from an e-mail message. |
|
||||
# |
|
||||
# The hook should exit with non-zero status after issuing an |
|
||||
# appropriate message if it wants to stop the commit. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "pre-applypatch". |
|
||||
|
|
||||
. git-sh-setup |
|
||||
precommit="$(git rev-parse --git-path hooks/pre-commit)" |
|
||||
test -x "$precommit" && exec "$precommit" ${1+"$@"} |
|
||||
: |
|
||||
@ -1,49 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to verify what is about to be committed. |
|
||||
# Called by "git commit" with no arguments. The hook should |
|
||||
# exit with non-zero status after issuing an appropriate message if |
|
||||
# it wants to stop the commit. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "pre-commit". |
|
||||
|
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1 |
|
||||
then |
|
||||
against=HEAD |
|
||||
else |
|
||||
# Initial commit: diff against an empty tree object |
|
||||
against=$(git hash-object -t tree /dev/null) |
|
||||
fi |
|
||||
|
|
||||
# If you want to allow non-ASCII filenames set this variable to true. |
|
||||
allownonascii=$(git config --type=bool hooks.allownonascii) |
|
||||
|
|
||||
# Redirect output to stderr. |
|
||||
exec 1>&2 |
|
||||
|
|
||||
# Cross platform projects tend to avoid non-ASCII filenames; prevent |
|
||||
# them from being added to the repository. We exploit the fact that the |
|
||||
# printable range starts at the space character and ends with tilde. |
|
||||
if [ "$allownonascii" != "true" ] && |
|
||||
# Note that the use of brackets around a tr range is ok here, (it's |
|
||||
# even required, for portability to Solaris 10's /usr/bin/tr), since |
|
||||
# the square bracket bytes happen to fall in the designated range. |
|
||||
test $(git diff --cached --name-only --diff-filter=A -z $against | |
|
||||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 |
|
||||
then |
|
||||
cat <<\EOF |
|
||||
Error: Attempt to add a non-ASCII file name. |
|
||||
|
|
||||
This can cause problems if you want to work with people on other platforms. |
|
||||
|
|
||||
To be portable it is advisable to rename the file. |
|
||||
|
|
||||
If you know what you are doing you can disable this check using: |
|
||||
|
|
||||
git config hooks.allownonascii true |
|
||||
EOF |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
# If there are whitespace errors, print the offending file names and fail. |
|
||||
exec git diff-index --check --cached $against -- |
|
||||
@ -1,13 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to verify what is about to be committed. |
|
||||
# Called by "git merge" with no arguments. The hook should |
|
||||
# exit with non-zero status after issuing an appropriate message to |
|
||||
# stderr if it wants to stop the merge commit. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "pre-merge-commit". |
|
||||
|
|
||||
. git-sh-setup |
|
||||
test -x "$GIT_DIR/hooks/pre-commit" && |
|
||||
exec "$GIT_DIR/hooks/pre-commit" |
|
||||
: |
|
||||
@ -1,53 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
|
|
||||
# An example hook script to verify what is about to be pushed. Called by "git |
|
||||
# push" after it has checked the remote status, but before anything has been |
|
||||
# pushed. If this script exits with a non-zero status nothing will be pushed. |
|
||||
# |
|
||||
# This hook is called with the following parameters: |
|
||||
# |
|
||||
# $1 -- Name of the remote to which the push is being done |
|
||||
# $2 -- URL to which the push is being done |
|
||||
# |
|
||||
# If pushing without using a named remote those arguments will be equal. |
|
||||
# |
|
||||
# Information about the commits which are being pushed is supplied as lines to |
|
||||
# the standard input in the form: |
|
||||
# |
|
||||
# <local ref> <local oid> <remote ref> <remote oid> |
|
||||
# |
|
||||
# This sample shows how to prevent push of commits where the log message starts |
|
||||
# with "WIP" (work in progress). |
|
||||
|
|
||||
remote="$1" |
|
||||
url="$2" |
|
||||
|
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0') |
|
||||
|
|
||||
while read local_ref local_oid remote_ref remote_oid |
|
||||
do |
|
||||
if test "$local_oid" = "$zero" |
|
||||
then |
|
||||
# Handle delete |
|
||||
: |
|
||||
else |
|
||||
if test "$remote_oid" = "$zero" |
|
||||
then |
|
||||
# New branch, examine all commits |
|
||||
range="$local_oid" |
|
||||
else |
|
||||
# Update to existing branch, examine new commits |
|
||||
range="$remote_oid..$local_oid" |
|
||||
fi |
|
||||
|
|
||||
# Check for WIP commit |
|
||||
commit=$(git rev-list -n 1 --grep '^WIP' "$range") |
|
||||
if test -n "$commit" |
|
||||
then |
|
||||
echo >&2 "Found WIP commit in $local_ref, not pushing" |
|
||||
exit 1 |
|
||||
fi |
|
||||
fi |
|
||||
done |
|
||||
|
|
||||
exit 0 |
|
||||
@ -1,169 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# Copyright (c) 2006, 2008 Junio C Hamano |
|
||||
# |
|
||||
# The "pre-rebase" hook is run just before "git rebase" starts doing |
|
||||
# its job, and can prevent the command from running by exiting with |
|
||||
# non-zero status. |
|
||||
# |
|
||||
# The hook is called with the following parameters: |
|
||||
# |
|
||||
# $1 -- the upstream the series was forked from. |
|
||||
# $2 -- the branch being rebased (or empty when rebasing the current branch). |
|
||||
# |
|
||||
# This sample shows how to prevent topic branches that are already |
|
||||
# merged to 'next' branch from getting rebased, because allowing it |
|
||||
# would result in rebasing already published history. |
|
||||
|
|
||||
publish=next |
|
||||
basebranch="$1" |
|
||||
if test "$#" = 2 |
|
||||
then |
|
||||
topic="refs/heads/$2" |
|
||||
else |
|
||||
topic=`git symbolic-ref HEAD` || |
|
||||
exit 0 ;# we do not interrupt rebasing detached HEAD |
|
||||
fi |
|
||||
|
|
||||
case "$topic" in |
|
||||
refs/heads/??/*) |
|
||||
;; |
|
||||
*) |
|
||||
exit 0 ;# we do not interrupt others. |
|
||||
;; |
|
||||
esac |
|
||||
|
|
||||
# Now we are dealing with a topic branch being rebased |
|
||||
# on top of master. Is it OK to rebase it? |
|
||||
|
|
||||
# Does the topic really exist? |
|
||||
git show-ref -q "$topic" || { |
|
||||
echo >&2 "No such branch $topic" |
|
||||
exit 1 |
|
||||
} |
|
||||
|
|
||||
# Is topic fully merged to master? |
|
||||
not_in_master=`git rev-list --pretty=oneline ^master "$topic"` |
|
||||
if test -z "$not_in_master" |
|
||||
then |
|
||||
echo >&2 "$topic is fully merged to master; better remove it." |
|
||||
exit 1 ;# we could allow it, but there is no point. |
|
||||
fi |
|
||||
|
|
||||
# Is topic ever merged to next? If so you should not be rebasing it. |
|
||||
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` |
|
||||
only_next_2=`git rev-list ^master ${publish} | sort` |
|
||||
if test "$only_next_1" = "$only_next_2" |
|
||||
then |
|
||||
not_in_topic=`git rev-list "^$topic" master` |
|
||||
if test -z "$not_in_topic" |
|
||||
then |
|
||||
echo >&2 "$topic is already up to date with master" |
|
||||
exit 1 ;# we could allow it, but there is no point. |
|
||||
else |
|
||||
exit 0 |
|
||||
fi |
|
||||
else |
|
||||
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` |
|
||||
/usr/bin/perl -e ' |
|
||||
my $topic = $ARGV[0]; |
|
||||
my $msg = "* $topic has commits already merged to public branch:\n"; |
|
||||
my (%not_in_next) = map { |
|
||||
/^([0-9a-f]+) /; |
|
||||
($1 => 1); |
|
||||
} split(/\n/, $ARGV[1]); |
|
||||
for my $elem (map { |
|
||||
/^([0-9a-f]+) (.*)$/; |
|
||||
[$1 => $2]; |
|
||||
} split(/\n/, $ARGV[2])) { |
|
||||
if (!exists $not_in_next{$elem->[0]}) { |
|
||||
if ($msg) { |
|
||||
print STDERR $msg; |
|
||||
undef $msg; |
|
||||
} |
|
||||
print STDERR " $elem->[1]\n"; |
|
||||
} |
|
||||
} |
|
||||
' "$topic" "$not_in_next" "$not_in_master" |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
<<\DOC_END |
|
||||
|
|
||||
This sample hook safeguards topic branches that have been |
|
||||
published from being rewound. |
|
||||
|
|
||||
The workflow assumed here is: |
|
||||
|
|
||||
* Once a topic branch forks from "master", "master" is never |
|
||||
merged into it again (either directly or indirectly). |
|
||||
|
|
||||
* Once a topic branch is fully cooked and merged into "master", |
|
||||
it is deleted. If you need to build on top of it to correct |
|
||||
earlier mistakes, a new topic branch is created by forking at |
|
||||
the tip of the "master". This is not strictly necessary, but |
|
||||
it makes it easier to keep your history simple. |
|
||||
|
|
||||
* Whenever you need to test or publish your changes to topic |
|
||||
branches, merge them into "next" branch. |
|
||||
|
|
||||
The script, being an example, hardcodes the publish branch name |
|
||||
to be "next", but it is trivial to make it configurable via |
|
||||
$GIT_DIR/config mechanism. |
|
||||
|
|
||||
With this workflow, you would want to know: |
|
||||
|
|
||||
(1) ... if a topic branch has ever been merged to "next". Young |
|
||||
topic branches can have stupid mistakes you would rather |
|
||||
clean up before publishing, and things that have not been |
|
||||
merged into other branches can be easily rebased without |
|
||||
affecting other people. But once it is published, you would |
|
||||
not want to rewind it. |
|
||||
|
|
||||
(2) ... if a topic branch has been fully merged to "master". |
|
||||
Then you can delete it. More importantly, you should not |
|
||||
build on top of it -- other people may already want to |
|
||||
change things related to the topic as patches against your |
|
||||
"master", so if you need further changes, it is better to |
|
||||
fork the topic (perhaps with the same name) afresh from the |
|
||||
tip of "master". |
|
||||
|
|
||||
Let's look at this example: |
|
||||
|
|
||||
o---o---o---o---o---o---o---o---o---o "next" |
|
||||
/ / / / |
|
||||
/ a---a---b A / / |
|
||||
/ / / / |
|
||||
/ / c---c---c---c B / |
|
||||
/ / / \ / |
|
||||
/ / / b---b C \ / |
|
||||
/ / / / \ / |
|
||||
---o---o---o---o---o---o---o---o---o---o---o "master" |
|
||||
|
|
||||
|
|
||||
A, B and C are topic branches. |
|
||||
|
|
||||
* A has one fix since it was merged up to "next". |
|
||||
|
|
||||
* B has finished. It has been fully merged up to "master" and "next", |
|
||||
and is ready to be deleted. |
|
||||
|
|
||||
* C has not merged to "next" at all. |
|
||||
|
|
||||
We would want to allow C to be rebased, refuse A, and encourage |
|
||||
B to be deleted. |
|
||||
|
|
||||
To compute (1): |
|
||||
|
|
||||
git rev-list ^master ^topic next |
|
||||
git rev-list ^master next |
|
||||
|
|
||||
if these match, topic has not merged in next at all. |
|
||||
|
|
||||
To compute (2): |
|
||||
|
|
||||
git rev-list master..topic |
|
||||
|
|
||||
if this is empty, it is fully merged to "master". |
|
||||
|
|
||||
DOC_END |
|
||||
@ -1,24 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to make use of push options. |
|
||||
# The example simply echoes all push options that start with 'echoback=' |
|
||||
# and rejects all pushes when the "reject" push option is used. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "pre-receive". |
|
||||
|
|
||||
if test -n "$GIT_PUSH_OPTION_COUNT" |
|
||||
then |
|
||||
i=0 |
|
||||
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" |
|
||||
do |
|
||||
eval "value=\$GIT_PUSH_OPTION_$i" |
|
||||
case "$value" in |
|
||||
echoback=*) |
|
||||
echo "echo from the pre-receive-hook: ${value#*=}" >&2 |
|
||||
;; |
|
||||
reject) |
|
||||
exit 1 |
|
||||
esac |
|
||||
i=$((i + 1)) |
|
||||
done |
|
||||
fi |
|
||||
@ -1,42 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to prepare the commit log message. |
|
||||
# Called by "git commit" with the name of the file that has the |
|
||||
# commit message, followed by the description of the commit |
|
||||
# message's source. The hook's purpose is to edit the commit |
|
||||
# message file. If the hook fails with a non-zero status, |
|
||||
# the commit is aborted. |
|
||||
# |
|
||||
# To enable this hook, rename this file to "prepare-commit-msg". |
|
||||
|
|
||||
# This hook includes three examples. The first one removes the |
|
||||
# "# Please enter the commit message..." help message. |
|
||||
# |
|
||||
# The second includes the output of "git diff --name-status -r" |
|
||||
# into the message, just before the "git status" output. It is |
|
||||
# commented because it doesn't cope with --amend or with squashed |
|
||||
# commits. |
|
||||
# |
|
||||
# The third example adds a Signed-off-by line to the message, that can |
|
||||
# still be edited. This is rarely a good idea. |
|
||||
|
|
||||
COMMIT_MSG_FILE=$1 |
|
||||
COMMIT_SOURCE=$2 |
|
||||
SHA1=$3 |
|
||||
|
|
||||
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" |
|
||||
|
|
||||
# case "$COMMIT_SOURCE,$SHA1" in |
|
||||
# ,|template,) |
|
||||
# /usr/bin/perl -i.bak -pe ' |
|
||||
# print "\n" . `git diff --cached --name-status -r` |
|
||||
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; |
|
||||
# *) ;; |
|
||||
# esac |
|
||||
|
|
||||
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') |
|
||||
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" |
|
||||
# if test -z "$COMMIT_SOURCE" |
|
||||
# then |
|
||||
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" |
|
||||
# fi |
|
||||
@ -1,78 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
|
|
||||
# An example hook script to update a checked-out tree on a git push. |
|
||||
# |
|
||||
# This hook is invoked by git-receive-pack(1) when it reacts to git |
|
||||
# push and updates reference(s) in its repository, and when the push |
|
||||
# tries to update the branch that is currently checked out and the |
|
||||
# receive.denyCurrentBranch configuration variable is set to |
|
||||
# updateInstead. |
|
||||
# |
|
||||
# By default, such a push is refused if the working tree and the index |
|
||||
# of the remote repository has any difference from the currently |
|
||||
# checked out commit; when both the working tree and the index match |
|
||||
# the current commit, they are updated to match the newly pushed tip |
|
||||
# of the branch. This hook is to be used to override the default |
|
||||
# behaviour; however the code below reimplements the default behaviour |
|
||||
# as a starting point for convenient modification. |
|
||||
# |
|
||||
# The hook receives the commit with which the tip of the current |
|
||||
# branch is going to be updated: |
|
||||
commit=$1 |
|
||||
|
|
||||
# It can exit with a non-zero status to refuse the push (when it does |
|
||||
# so, it must not modify the index or the working tree). |
|
||||
die () { |
|
||||
echo >&2 "$*" |
|
||||
exit 1 |
|
||||
} |
|
||||
|
|
||||
# Or it can make any necessary changes to the working tree and to the |
|
||||
# index to bring them to the desired state when the tip of the current |
|
||||
# branch is updated to the new commit, and exit with a zero status. |
|
||||
# |
|
||||
# For example, the hook can simply run git read-tree -u -m HEAD "$1" |
|
||||
# in order to emulate git fetch that is run in the reverse direction |
|
||||
# with git push, as the two-tree form of git read-tree -u -m is |
|
||||
# essentially the same as git switch or git checkout that switches |
|
||||
# branches while keeping the local changes in the working tree that do |
|
||||
# not interfere with the difference between the branches. |
|
||||
|
|
||||
# The below is a more-or-less exact translation to shell of the C code |
|
||||
# for the default behaviour for git's push-to-checkout hook defined in |
|
||||
# the push_to_deploy() function in builtin/receive-pack.c. |
|
||||
# |
|
||||
# Note that the hook will be executed from the repository directory, |
|
||||
# not from the working tree, so if you want to perform operations on |
|
||||
# the working tree, you will have to adapt your code accordingly, e.g. |
|
||||
# by adding "cd .." or using relative paths. |
|
||||
|
|
||||
if ! git update-index -q --ignore-submodules --refresh |
|
||||
then |
|
||||
die "Up-to-date check failed" |
|
||||
fi |
|
||||
|
|
||||
if ! git diff-files --quiet --ignore-submodules -- |
|
||||
then |
|
||||
die "Working directory has unstaged changes" |
|
||||
fi |
|
||||
|
|
||||
# This is a rough translation of: |
|
||||
# |
|
||||
# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX |
|
||||
if git cat-file -e HEAD 2>/dev/null |
|
||||
then |
|
||||
head=HEAD |
|
||||
else |
|
||||
head=$(git hash-object -t tree --stdin </dev/null) |
|
||||
fi |
|
||||
|
|
||||
if ! git diff-index --quiet --cached --ignore-submodules $head -- |
|
||||
then |
|
||||
die "Working directory has staged changes" |
|
||||
fi |
|
||||
|
|
||||
if ! git read-tree -u -m "$commit" |
|
||||
then |
|
||||
die "Could not update working tree to new HEAD" |
|
||||
fi |
|
||||
@ -1,128 +0,0 @@ |
|||||
#!/bin/sh |
|
||||
# |
|
||||
# An example hook script to block unannotated tags from entering. |
|
||||
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new |
|
||||
# |
|
||||
# To enable this hook, rename this file to "update". |
|
||||
# |
|
||||
# Config |
|
||||
# ------ |
|
||||
# hooks.allowunannotated |
|
||||
# This boolean sets whether unannotated tags will be allowed into the |
|
||||
# repository. By default they won't be. |
|
||||
# hooks.allowdeletetag |
|
||||
# This boolean sets whether deleting tags will be allowed in the |
|
||||
# repository. By default they won't be. |
|
||||
# hooks.allowmodifytag |
|
||||
# This boolean sets whether a tag may be modified after creation. By default |
|
||||
# it won't be. |
|
||||
# hooks.allowdeletebranch |
|
||||
# This boolean sets whether deleting branches will be allowed in the |
|
||||
# repository. By default they won't be. |
|
||||
# hooks.denycreatebranch |
|
||||
# This boolean sets whether remotely creating branches will be denied |
|
||||
# in the repository. By default this is allowed. |
|
||||
# |
|
||||
|
|
||||
# --- Command line |
|
||||
refname="$1" |
|
||||
oldrev="$2" |
|
||||
newrev="$3" |
|
||||
|
|
||||
# --- Safety check |
|
||||
if [ -z "$GIT_DIR" ]; then |
|
||||
echo "Don't run this script from the command line." >&2 |
|
||||
echo " (if you want, you could supply GIT_DIR then run" >&2 |
|
||||
echo " $0 <ref> <oldrev> <newrev>)" >&2 |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then |
|
||||
echo "usage: $0 <ref> <oldrev> <newrev>" >&2 |
|
||||
exit 1 |
|
||||
fi |
|
||||
|
|
||||
# --- Config |
|
||||
allowunannotated=$(git config --type=bool hooks.allowunannotated) |
|
||||
allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch) |
|
||||
denycreatebranch=$(git config --type=bool hooks.denycreatebranch) |
|
||||
allowdeletetag=$(git config --type=bool hooks.allowdeletetag) |
|
||||
allowmodifytag=$(git config --type=bool hooks.allowmodifytag) |
|
||||
|
|
||||
# check for no description |
|
||||
projectdesc=$(sed -e '1q' "$GIT_DIR/description") |
|
||||
case "$projectdesc" in |
|
||||
"Unnamed repository"* | "") |
|
||||
echo "*** Project description file hasn't been set" >&2 |
|
||||
exit 1 |
|
||||
;; |
|
||||
esac |
|
||||
|
|
||||
# --- Check types |
|
||||
# if $newrev is 0000...0000, it's a commit to delete a ref. |
|
||||
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0') |
|
||||
if [ "$newrev" = "$zero" ]; then |
|
||||
newrev_type=delete |
|
||||
else |
|
||||
newrev_type=$(git cat-file -t $newrev) |
|
||||
fi |
|
||||
|
|
||||
case "$refname","$newrev_type" in |
|
||||
refs/tags/*,commit) |
|
||||
# un-annotated tag |
|
||||
short_refname=${refname##refs/tags/} |
|
||||
if [ "$allowunannotated" != "true" ]; then |
|
||||
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 |
|
||||
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 |
|
||||
exit 1 |
|
||||
fi |
|
||||
;; |
|
||||
refs/tags/*,delete) |
|
||||
# delete tag |
|
||||
if [ "$allowdeletetag" != "true" ]; then |
|
||||
echo "*** Deleting a tag is not allowed in this repository" >&2 |
|
||||
exit 1 |
|
||||
fi |
|
||||
;; |
|
||||
refs/tags/*,tag) |
|
||||
# annotated tag |
|
||||
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 |
|
||||
then |
|
||||
echo "*** Tag '$refname' already exists." >&2 |
|
||||
echo "*** Modifying a tag is not allowed in this repository." >&2 |
|
||||
exit 1 |
|
||||
fi |
|
||||
;; |
|
||||
refs/heads/*,commit) |
|
||||
# branch |
|
||||
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then |
|
||||
echo "*** Creating a branch is not allowed in this repository" >&2 |
|
||||
exit 1 |
|
||||
fi |
|
||||
;; |
|
||||
refs/heads/*,delete) |
|
||||
# delete branch |
|
||||
if [ "$allowdeletebranch" != "true" ]; then |
|
||||
echo "*** Deleting a branch is not allowed in this repository" >&2 |
|
||||
exit 1 |
|
||||
fi |
|
||||
;; |
|
||||
refs/remotes/*,commit) |
|
||||
# tracking branch |
|
||||
;; |
|
||||
refs/remotes/*,delete) |
|
||||
# delete tracking branch |
|
||||
if [ "$allowdeletebranch" != "true" ]; then |
|
||||
echo "*** Deleting a tracking branch is not allowed in this repository" >&2 |
|
||||
exit 1 |
|
||||
fi |
|
||||
;; |
|
||||
*) |
|
||||
# Anything else (is there anything else?) |
|
||||
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 |
|
||||
exit 1 |
|
||||
;; |
|
||||
esac |
|
||||
|
|
||||
# --- Finished |
|
||||
exit 0 |
|
||||
@ -1,6 +0,0 @@ |
|||||
# git ls-files --others --exclude-from=.git/info/exclude |
|
||||
# Lines that start with '#' are comments. |
|
||||
# For a project mostly in C, the following would be a good set of |
|
||||
# exclude patterns (uncomment them if you want to use them): |
|
||||
# *.[oa] |
|
||||
# *~ |
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue