Files

589 lines
19 KiB
C++
Raw Permalink Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#include "AudioFormatOpus.h"
#include "Audio.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Serialization/MemoryWriter.h"
#include "Modules/ModuleManager.h"
#include "Interfaces/IAudioFormat.h"
#include "Interfaces/IAudioFormatModule.h"
#include "Decoders/OpusAudioInfo.h"
#include "Decoders/VorbisAudioInfo.h" // for VorbisChannelInfo
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3232619) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3121996 on 2016/09/12 by Ben.Marsh Add support for Visual Studio 2017 (aka "15"; assuming consistent naming with other versions until final name is announced). * Compiler, STL implementation and CRT are binary compatible with VS2015 (see https://blogs.msdn.microsoft.com/vcblog/2016/08/24/c1417-features-and-stl-fixes-in-vs-15-preview-4/), so no new third-party libraries needed so far. WindowsPlatform.GetVisualStudioCompilerVersionName() returns "2015" as a result. * Default compiler for compiling and generating project files is still VS 2015 for now. Pass -2017 on the command line to GenerateProjectFiles.bat to generate VS2017 projects. Projects generated for VS2017 will use the 2017 compiler by default. * Visual Studio source code accessor can talk to VS 2017 instances. * Added a VS2017 configuration for UnrealVS, and added precompiled vsix package. * Switched GetVSComnTools to check the SOFTWARE\Microsoft\VisualStudio\SxS\VS7 registry key rather than the individual product install registry key. "15" doesn't seem to have it's own "InstallDir" key, but this system seems to work for all versions of Visual Studio (including previous releases of VS Express). * Removed ATL dependency from VisualStudioSourceCodeAccessor. It's not installed with VS by default any more, and is only used for a couple of smart pointer classes. Tested running the editor and packaging TP_Flying for Win64. Packaging from the editor still defaults to using the 2015 compiler, so ConfigureToolchain() needs to be overriden from the .target.cs file if multiple Visual Studio versions are installed. Change 3189363 on 2016/11/07 by Ben.Marsh Consolidate functionality for determining the path to MSBuild.exe to use for compiling UE4 tools into a single batch file (GetMSBuildToolPath) and fix "Clean" not working on PS4 due to include/library paths being set to something by the Visual Studio environment. Change 3210598 on 2016/11/27 by Ben.Marsh UBT: Prevent the name of each file compiled being output twice on XboxOne. Compiler already outputs this string; the action doesn't need to. Change 3210601 on 2016/11/27 by Ben.Marsh PR #2967: Add silent version of switch game version (Contributed by EricLeeFriedman) Change 3210602 on 2016/11/27 by Ben.Marsh PR #2964: GitDependencies shouldn't try to clean up working directory files that are excluded or ignored (Contributed by joelmcginnis) Change 3210605 on 2016/11/27 by Ben.Marsh UGS: Add a warning when syncing latest would remove changes that have been authored locally. Typically happens when working with precompiled binaries. Change 3211656 on 2016/11/28 by Ben.Marsh UBT: Move ModuleRules and TargetRules into their own file. Change 3211797 on 2016/11/28 by Ben.Marsh UBT: Remove utility functions from TargetRules for checking different classes of target types. Moving TargetRules to be data-only. Change 3211833 on 2016/11/28 by Ben.Marsh UBT: Remove overridable configuration name from target rules. This feature is not used anywhere. Change 3211859 on 2016/11/28 by Ben.Marsh UBT: Deprecate the GetGeneratedCodeVersion() callback in favor of a member variable instead. Change 3211942 on 2016/11/28 by Ben.Marsh UBT: Remove legacy code which tries to change the output paths for console binaries. Output paths for monolithic binaries are always in the project folder now. Change 3215333 on 2016/11/30 by Ben.Marsh UBT: Replace the GetSupportedPlatforms() callback on TargetRules with a SupportedPlatforms attribute. Since a TargetRules object can only be instantiated with an actual platform, it doesn't make sense for it to be an instance method. Change 3215482 on 2016/11/30 by Ben.Marsh UBT: Remove the GetSupportedConfigurations() callback on the TargetRules class. A configuration is required to construct a TargetRules instance, so it doesn't make sense to need to call an instance method to find out which configurations are supported. Change 3215743 on 2016/11/30 by Ben.Marsh UBT: Deprecate the TargetRules.ShouldCompileMonolithic() function: this function requires access to the global command line to operate correctly, which prevents creating target-specific instances, and does not use the platform/configuration passed into the TargetRules constructor. Rather than being a callback, the LinkType field can now be set to TargetLinkType.Modular or TargetLinkType.Monolithic from the constructor as appropriate. The default value (TargetLinkType.Default) results in the default link type for the target type being used. Parsing of the command-line overrides is now done when building the TargetDescriptor. Change 3215778 on 2016/11/30 by Ben.Marsh UBT: Mark overrides of the TargetRules.GetModulesToPrecompile method as obsolete. Change 3217681 on 2016/12/01 by Ben.Marsh UAT: Prevent UE4Build deleting .modules files when running with the -Clean argument; these files are artifacts generated by UBT itself, not by the exported XGE script. Change 3217723 on 2016/12/01 by Ben.Marsh UBT: Run pre- and post-build steps for all plugins that are being built, not just those that are enabled. Change 3217930 on 2016/12/01 by Ben.Marsh UGS: Add a perforce settings window, allowing users to set optional values for tuning Perforce performance on unreliable connections. Change 3218762 on 2016/12/02 by Ben.Marsh Enable warnings whenever an undefined macro is used in a constant expression inside an #if or #elif directive, and fix existing violations. Change 3219161 on 2016/12/02 by Ben.Marsh Core: Use the directory containing the current module to derive the UE4 base directory, rather than the executable directory. Allows UE4 to be hosted by a process in a different directory. Change 3219197 on 2016/12/02 by Ben.Marsh Core: When loading a DLL from disk, convert any relative paths to absolute before calling LoadLibrary. The OS resolves these paths relative to the directory containing the process executable -- not the working directory -- so paths need to be absolute to allow UE4 to be hosted by a process elsewhere. Change 3219209 on 2016/12/02 by Ben.Marsh Replace some calls to LoadLibrary() with FPlatformProcess::GetDllHandle(). The UE4 function makes sure that relative paths are resolved relative to the correct base directory, which is important when the host executable is not in Engine/Binaries/Win64. Change 3219610 on 2016/12/02 by Ben.Marsh Add the -q (quiet) option to the Mac unzip command, since it's creating too much log output to be useful. Change 3219731 on 2016/12/02 by Ben.Marsh UBT: Add option to disable IWYU checks regarding the use of monolithic headers (Engine.h, UnrealEd.h, etc...) and including the matching header for a cpp file first. bEnforceIWYU can be set to false in UEBuildConfiguration or on a per-module basis in the module rules. Change 3220796 on 2016/12/04 by Ben.Marsh Remove PrepForUATPackageOrDeploy from the UEBuildDeploy base class. It never has to be accessed through the base class anyway. Change 3220825 on 2016/12/04 by Ben.Marsh UBT: Change all executors to derive from a common base class (ActionExecutor). Change 3220834 on 2016/12/04 by Ben.Marsh UBT: Remove the global CommandLineContains() function. Change 3222706 on 2016/12/05 by Ben.Marsh Merging CL 3221949 from //UE4/Release-4.14: Fixes to code analysis template causing problems with stock install of VS2017. Change 3222712 on 2016/12/05 by Ben.Marsh Merging CL 3222021 from //UE4/Release-4.14: Change detection of MSBuild.exe path to match GetMSBuildPath.bat Change 3223628 on 2016/12/06 by Ben.Marsh Merging CL 3223369 from 4.14 branch: Use the same logic as GetMsBuildPath.bat inside FDesktopPlatformBase to determine path to MSBuild.exe Change 3223817 on 2016/12/06 by Ben.Marsh Remove non-ANSI characters from source files. Compiler/P4 support is patchy for this, and we want to avoid failing prey to different codepages resulting in different interpretations of the source text. Change 3224046 on 2016/12/06 by Ben.Marsh Remove the need for the iOS/TVOS deployment instances to have an IOSPlatformContext instance. The only dependency between the two -- a call to GetRequiredCapabilities() -- is now implemented by querying the INI file for the supported architectures when neeeded. Change 3224792 on 2016/12/07 by Ben.Marsh UBT: Touch PCH wrapper files whenever the file they include is newer rather than writing the timestamp for the included file into it as a comment. Allows use of ccache and similar tools. Change 3225212 on 2016/12/07 by Ben.Marsh UBT: Move settings required for deployment into the UEBuildDeployTarget class, allowing them to be serialized to and from a file the intermediate directory without having to construct a phony UEBuildTarget to deploy. Deployment is now performed by a method on UEBuildPlatform, rather than having to create a UEBuildPlatformContext and using that to create a UEBuildDeploy object. The -prepfordeploy UBT invocation from UAT, previously done by the per-platform PostBuildTarget() callback when building with XGE, is replaced by running UBT with a path to the serialized UEBuildDeployTarget object, and can be done in a platform agnostic manner. Change 3226310 on 2016/12/07 by Ben.Marsh PR #3015: Fixes wrong VSC++ flags being passed for .c files (Contributed by badlogic) Change 3228273 on 2016/12/08 by Ben.Marsh Update copyright notices for QAGame. Change 3229166 on 2016/12/09 by Ben.Marsh UBT: Rewritten config file parser. No longer requires hard-coded list of sections to be parsed, but parses them on demand. Measured 2x faster read speeds (largely due to eliminating construction of temporary string objects when parsing each line, to trim whitespace and so on). Also includes an attribute-driven parser, which allows reading named config values for marked up fields in an object. Change 3230601 on 2016/12/12 by Ben.Marsh Swarm: Change Swarm AgentInterface to target .NET framework 4.5, to remove dependency on having 4.0 framework installed. Change 3230737 on 2016/12/12 by Ben.Marsh UAT: Stop UE4Build deriving from CommandUtils. Confusing pattern, and causes problems trying to access instance variables that are only set for build commands. Change 3230751 on 2016/12/12 by Ben.Marsh UAT: Move ParseParam*() functions which use the instanced parameter list from CommandUtils to BuildCommand, since that's the only thing that it's instanced for. Change 3230804 on 2016/12/12 by Ben.Marsh UBT: Add the IsPromotedBuild flag to Build.version, and only set the bFormalBuild flag in UBT if it's set. This allows UGS users to avoid having to compile separate RC files for each output binary. Change 3230831 on 2016/12/12 by Ben.Marsh UGS: Warn when trying to switch streams if files are checked out. Change 3231281 on 2016/12/12 by Chad.Garyet Fixing a bug where .modules files were getting put into receipts with their absolute path instead of their relative one Change 3231496 on 2016/12/12 by Ben.Marsh Disable code analysis in CrashReportProcess; causes warnings when compiled with VS2015. Change 3231979 on 2016/12/12 by Ben.Marsh UBT: Suppress LNK4221 when generating import libraries. This can happen often when generating import libraries separately to linking. Change 3232619 on 2016/12/13 by Ben.Marsh Fix "#pragma once in main file" errors on Mac, which are occurring in //UE4/Main. [CL 3232653 by Ben Marsh in Main branch]
2016-12-13 11:58:16 -05:00
THIRD_PARTY_INCLUDES_START
#include "opus_multistream.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3232619) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3121996 on 2016/09/12 by Ben.Marsh Add support for Visual Studio 2017 (aka "15"; assuming consistent naming with other versions until final name is announced). * Compiler, STL implementation and CRT are binary compatible with VS2015 (see https://blogs.msdn.microsoft.com/vcblog/2016/08/24/c1417-features-and-stl-fixes-in-vs-15-preview-4/), so no new third-party libraries needed so far. WindowsPlatform.GetVisualStudioCompilerVersionName() returns "2015" as a result. * Default compiler for compiling and generating project files is still VS 2015 for now. Pass -2017 on the command line to GenerateProjectFiles.bat to generate VS2017 projects. Projects generated for VS2017 will use the 2017 compiler by default. * Visual Studio source code accessor can talk to VS 2017 instances. * Added a VS2017 configuration for UnrealVS, and added precompiled vsix package. * Switched GetVSComnTools to check the SOFTWARE\Microsoft\VisualStudio\SxS\VS7 registry key rather than the individual product install registry key. "15" doesn't seem to have it's own "InstallDir" key, but this system seems to work for all versions of Visual Studio (including previous releases of VS Express). * Removed ATL dependency from VisualStudioSourceCodeAccessor. It's not installed with VS by default any more, and is only used for a couple of smart pointer classes. Tested running the editor and packaging TP_Flying for Win64. Packaging from the editor still defaults to using the 2015 compiler, so ConfigureToolchain() needs to be overriden from the .target.cs file if multiple Visual Studio versions are installed. Change 3189363 on 2016/11/07 by Ben.Marsh Consolidate functionality for determining the path to MSBuild.exe to use for compiling UE4 tools into a single batch file (GetMSBuildToolPath) and fix "Clean" not working on PS4 due to include/library paths being set to something by the Visual Studio environment. Change 3210598 on 2016/11/27 by Ben.Marsh UBT: Prevent the name of each file compiled being output twice on XboxOne. Compiler already outputs this string; the action doesn't need to. Change 3210601 on 2016/11/27 by Ben.Marsh PR #2967: Add silent version of switch game version (Contributed by EricLeeFriedman) Change 3210602 on 2016/11/27 by Ben.Marsh PR #2964: GitDependencies shouldn't try to clean up working directory files that are excluded or ignored (Contributed by joelmcginnis) Change 3210605 on 2016/11/27 by Ben.Marsh UGS: Add a warning when syncing latest would remove changes that have been authored locally. Typically happens when working with precompiled binaries. Change 3211656 on 2016/11/28 by Ben.Marsh UBT: Move ModuleRules and TargetRules into their own file. Change 3211797 on 2016/11/28 by Ben.Marsh UBT: Remove utility functions from TargetRules for checking different classes of target types. Moving TargetRules to be data-only. Change 3211833 on 2016/11/28 by Ben.Marsh UBT: Remove overridable configuration name from target rules. This feature is not used anywhere. Change 3211859 on 2016/11/28 by Ben.Marsh UBT: Deprecate the GetGeneratedCodeVersion() callback in favor of a member variable instead. Change 3211942 on 2016/11/28 by Ben.Marsh UBT: Remove legacy code which tries to change the output paths for console binaries. Output paths for monolithic binaries are always in the project folder now. Change 3215333 on 2016/11/30 by Ben.Marsh UBT: Replace the GetSupportedPlatforms() callback on TargetRules with a SupportedPlatforms attribute. Since a TargetRules object can only be instantiated with an actual platform, it doesn't make sense for it to be an instance method. Change 3215482 on 2016/11/30 by Ben.Marsh UBT: Remove the GetSupportedConfigurations() callback on the TargetRules class. A configuration is required to construct a TargetRules instance, so it doesn't make sense to need to call an instance method to find out which configurations are supported. Change 3215743 on 2016/11/30 by Ben.Marsh UBT: Deprecate the TargetRules.ShouldCompileMonolithic() function: this function requires access to the global command line to operate correctly, which prevents creating target-specific instances, and does not use the platform/configuration passed into the TargetRules constructor. Rather than being a callback, the LinkType field can now be set to TargetLinkType.Modular or TargetLinkType.Monolithic from the constructor as appropriate. The default value (TargetLinkType.Default) results in the default link type for the target type being used. Parsing of the command-line overrides is now done when building the TargetDescriptor. Change 3215778 on 2016/11/30 by Ben.Marsh UBT: Mark overrides of the TargetRules.GetModulesToPrecompile method as obsolete. Change 3217681 on 2016/12/01 by Ben.Marsh UAT: Prevent UE4Build deleting .modules files when running with the -Clean argument; these files are artifacts generated by UBT itself, not by the exported XGE script. Change 3217723 on 2016/12/01 by Ben.Marsh UBT: Run pre- and post-build steps for all plugins that are being built, not just those that are enabled. Change 3217930 on 2016/12/01 by Ben.Marsh UGS: Add a perforce settings window, allowing users to set optional values for tuning Perforce performance on unreliable connections. Change 3218762 on 2016/12/02 by Ben.Marsh Enable warnings whenever an undefined macro is used in a constant expression inside an #if or #elif directive, and fix existing violations. Change 3219161 on 2016/12/02 by Ben.Marsh Core: Use the directory containing the current module to derive the UE4 base directory, rather than the executable directory. Allows UE4 to be hosted by a process in a different directory. Change 3219197 on 2016/12/02 by Ben.Marsh Core: When loading a DLL from disk, convert any relative paths to absolute before calling LoadLibrary. The OS resolves these paths relative to the directory containing the process executable -- not the working directory -- so paths need to be absolute to allow UE4 to be hosted by a process elsewhere. Change 3219209 on 2016/12/02 by Ben.Marsh Replace some calls to LoadLibrary() with FPlatformProcess::GetDllHandle(). The UE4 function makes sure that relative paths are resolved relative to the correct base directory, which is important when the host executable is not in Engine/Binaries/Win64. Change 3219610 on 2016/12/02 by Ben.Marsh Add the -q (quiet) option to the Mac unzip command, since it's creating too much log output to be useful. Change 3219731 on 2016/12/02 by Ben.Marsh UBT: Add option to disable IWYU checks regarding the use of monolithic headers (Engine.h, UnrealEd.h, etc...) and including the matching header for a cpp file first. bEnforceIWYU can be set to false in UEBuildConfiguration or on a per-module basis in the module rules. Change 3220796 on 2016/12/04 by Ben.Marsh Remove PrepForUATPackageOrDeploy from the UEBuildDeploy base class. It never has to be accessed through the base class anyway. Change 3220825 on 2016/12/04 by Ben.Marsh UBT: Change all executors to derive from a common base class (ActionExecutor). Change 3220834 on 2016/12/04 by Ben.Marsh UBT: Remove the global CommandLineContains() function. Change 3222706 on 2016/12/05 by Ben.Marsh Merging CL 3221949 from //UE4/Release-4.14: Fixes to code analysis template causing problems with stock install of VS2017. Change 3222712 on 2016/12/05 by Ben.Marsh Merging CL 3222021 from //UE4/Release-4.14: Change detection of MSBuild.exe path to match GetMSBuildPath.bat Change 3223628 on 2016/12/06 by Ben.Marsh Merging CL 3223369 from 4.14 branch: Use the same logic as GetMsBuildPath.bat inside FDesktopPlatformBase to determine path to MSBuild.exe Change 3223817 on 2016/12/06 by Ben.Marsh Remove non-ANSI characters from source files. Compiler/P4 support is patchy for this, and we want to avoid failing prey to different codepages resulting in different interpretations of the source text. Change 3224046 on 2016/12/06 by Ben.Marsh Remove the need for the iOS/TVOS deployment instances to have an IOSPlatformContext instance. The only dependency between the two -- a call to GetRequiredCapabilities() -- is now implemented by querying the INI file for the supported architectures when neeeded. Change 3224792 on 2016/12/07 by Ben.Marsh UBT: Touch PCH wrapper files whenever the file they include is newer rather than writing the timestamp for the included file into it as a comment. Allows use of ccache and similar tools. Change 3225212 on 2016/12/07 by Ben.Marsh UBT: Move settings required for deployment into the UEBuildDeployTarget class, allowing them to be serialized to and from a file the intermediate directory without having to construct a phony UEBuildTarget to deploy. Deployment is now performed by a method on UEBuildPlatform, rather than having to create a UEBuildPlatformContext and using that to create a UEBuildDeploy object. The -prepfordeploy UBT invocation from UAT, previously done by the per-platform PostBuildTarget() callback when building with XGE, is replaced by running UBT with a path to the serialized UEBuildDeployTarget object, and can be done in a platform agnostic manner. Change 3226310 on 2016/12/07 by Ben.Marsh PR #3015: Fixes wrong VSC++ flags being passed for .c files (Contributed by badlogic) Change 3228273 on 2016/12/08 by Ben.Marsh Update copyright notices for QAGame. Change 3229166 on 2016/12/09 by Ben.Marsh UBT: Rewritten config file parser. No longer requires hard-coded list of sections to be parsed, but parses them on demand. Measured 2x faster read speeds (largely due to eliminating construction of temporary string objects when parsing each line, to trim whitespace and so on). Also includes an attribute-driven parser, which allows reading named config values for marked up fields in an object. Change 3230601 on 2016/12/12 by Ben.Marsh Swarm: Change Swarm AgentInterface to target .NET framework 4.5, to remove dependency on having 4.0 framework installed. Change 3230737 on 2016/12/12 by Ben.Marsh UAT: Stop UE4Build deriving from CommandUtils. Confusing pattern, and causes problems trying to access instance variables that are only set for build commands. Change 3230751 on 2016/12/12 by Ben.Marsh UAT: Move ParseParam*() functions which use the instanced parameter list from CommandUtils to BuildCommand, since that's the only thing that it's instanced for. Change 3230804 on 2016/12/12 by Ben.Marsh UBT: Add the IsPromotedBuild flag to Build.version, and only set the bFormalBuild flag in UBT if it's set. This allows UGS users to avoid having to compile separate RC files for each output binary. Change 3230831 on 2016/12/12 by Ben.Marsh UGS: Warn when trying to switch streams if files are checked out. Change 3231281 on 2016/12/12 by Chad.Garyet Fixing a bug where .modules files were getting put into receipts with their absolute path instead of their relative one Change 3231496 on 2016/12/12 by Ben.Marsh Disable code analysis in CrashReportProcess; causes warnings when compiled with VS2015. Change 3231979 on 2016/12/12 by Ben.Marsh UBT: Suppress LNK4221 when generating import libraries. This can happen often when generating import libraries separately to linking. Change 3232619 on 2016/12/13 by Ben.Marsh Fix "#pragma once in main file" errors on Mac, which are occurring in //UE4/Main. [CL 3232653 by Ben Marsh in Main branch]
2016-12-13 11:58:16 -05:00
THIRD_PARTY_INCLUDES_END
/** Use UE memory allocation or Opus */
#define USE_UE_MEM_ALLOC 1
#define SAMPLE_SIZE ( ( uint32 )sizeof( short ) )
static FName NAME_OPUS(TEXT("OPUS"));
/**
* IAudioFormat, audio compression abstraction
**/
class FAudioFormatOpus : public IAudioFormat
{
enum
{
/** Version for OPUS format, this becomes part of the DDC key. */
UE_AUDIO_OPUS_VER = 12,
};
public:
bool AllowParallelBuild() const override
{
return true;
}
uint16 GetVersion(FName Format) const override
{
check(Format == NAME_OPUS);
return UE_AUDIO_OPUS_VER;
}
void GetSupportedFormats(TArray<FName>& OutFormats) const override
{
OutFormats.Add(NAME_OPUS);
}
bool Cook(FName Format, const TArray<uint8>& SrcBuffer, FSoundQualityInfo& QualityInfo, TArray<uint8>& CompressedDataStore) const override
{
TRACE_CPUPROFILER_EVENT_SCOPE(FAudioFormatOpus::Cook);
check(Format == NAME_OPUS);
// For audio encoding purposes we want Full Band encoding with a 20ms frame size.
const uint32 kOpusSampleRate = GetMatchingOpusSampleRate(QualityInfo.SampleRate);
const int32 kOpusFrameSizeMs = 20;
// Calculate frame size required by Opus
const int32 kOpusFrameSizeSamples = (kOpusSampleRate * kOpusFrameSizeMs) / 1000;
const uint32 kSampleStride = SAMPLE_SIZE * QualityInfo.NumChannels;
const int32 kBytesPerFrame = kOpusFrameSizeSamples * kSampleStride;
// Number of silent samples to prepend that get removed after decoding.
const int32 kPrerollSkipCount = kOpusFrameSizeSamples * (80 / kOpusFrameSizeMs); // 80ms worth
int32 NumPaddingSamplesAtEnd = 0;
// Remember the actual number of samples
uint32 TrueSampleCount = SrcBuffer.Num() / kSampleStride;
// Prepend the initial silence.
TArray<uint8> SrcBufferCopy = SrcBuffer;
SrcBufferCopy.InsertZeroed(0, kPrerollSkipCount * SAMPLE_SIZE * QualityInfo.NumChannels);
// Initialise the Opus encoder
OpusEncoder* Encoder = NULL;
int32 EncError = 0;
#if USE_UE_MEM_ALLOC
int32 EncSize = opus_encoder_get_size(QualityInfo.NumChannels);
Encoder = (OpusEncoder*)FMemory::Malloc(EncSize);
EncError = opus_encoder_init(Encoder, kOpusSampleRate, QualityInfo.NumChannels, OPUS_APPLICATION_AUDIO);
#else
Encoder = opus_encoder_create(kOpusSampleRate, QualityInfo.NumChannels, OPUS_APPLICATION_AUDIO, &EncError);
#endif
if (EncError != OPUS_OK)
{
Destroy(Encoder);
return false;
}
int32 BitRate = GetBitRateFromQuality(QualityInfo);
opus_encoder_ctl(Encoder, OPUS_SET_BITRATE(BitRate));
// Get the number of pre-skip samples. These are to be skipped in addition to the initial silence.
int32 PreSkip = 0;
opus_encoder_ctl(Encoder, OPUS_GET_LOOKAHEAD(&PreSkip));
// We add silence to the end of the buffer as indicated by the pre-skip so we get this implicit
// decoder delay accounted for at the end. Otherwise the last samples may not be emitted by the decoder.
SrcBufferCopy.AddZeroed(PreSkip * SAMPLE_SIZE * QualityInfo.NumChannels);
// Create a buffer to store compressed data
CompressedDataStore.Empty();
FMemoryWriter CompressedData(CompressedDataStore);
int32 SrcBufferOffset = 0;
// Calc frame and sample count
int64 FramesToEncode = SrcBufferCopy.Num() / kBytesPerFrame;
// Pad the end of data with zeroes if it isn't exactly the size of a frame.
if (SrcBufferCopy.Num() % kBytesPerFrame != 0)
{
int32 FrameDiff = kBytesPerFrame - (SrcBufferCopy.Num() % kBytesPerFrame);
SrcBufferCopy.AddZeroed(FrameDiff);
++FramesToEncode;
NumPaddingSamplesAtEnd = FrameDiff / (SAMPLE_SIZE * QualityInfo.NumChannels);
}
check(QualityInfo.NumChannels <= MAX_uint8);
check(FramesToEncode <= MAX_uint32);
FOpusAudioInfo::FHeader Hdr;
Hdr.NumChannels = QualityInfo.NumChannels;
Hdr.SampleRate = QualityInfo.SampleRate;
Hdr.EncodedSampleRate = kOpusSampleRate;
Hdr.ActiveSampleCount = TrueSampleCount;
Hdr.NumEncodedFrames = (uint32)FramesToEncode;
Hdr.NumPreSkipSamples = PreSkip;
Hdr.NumSilentSamplesAtBeginning = kPrerollSkipCount;
Hdr.NumSilentSamplesAtEnd = NumPaddingSamplesAtEnd;
SerializeHeaderData(CompressedData, Hdr);
// Temporary storage with more than enough to store any compressed frame
TArray<uint8> TempCompressedData;
TempCompressedData.AddUninitialized(kBytesPerFrame);
while (SrcBufferOffset < SrcBufferCopy.Num())
{
int32 CompressedLength = opus_encode(Encoder, (const opus_int16*)(SrcBufferCopy.GetData() + SrcBufferOffset), kOpusFrameSizeSamples, TempCompressedData.GetData(), TempCompressedData.Num());
if (CompressedLength < 0)
{
const char* ErrorStr = opus_strerror(CompressedLength);
UE_LOG(LogAudio, Warning, TEXT("Failed to encode: [%d] %s"), CompressedLength, ANSI_TO_TCHAR(ErrorStr));
Destroy(Encoder);
CompressedDataStore.Empty();
return false;
}
else
{
// Store frame length and copy compressed data before incrementing pointers
check(CompressedLength < MAX_uint16);
SerialiseFrameData(CompressedData, TempCompressedData.GetData(), CompressedLength);
SrcBufferOffset += kBytesPerFrame;
}
}
Destroy(Encoder);
return CompressedDataStore.Num() > 0;
}
bool CookSurround(FName Format, const TArray<TArray<uint8> >& SrcBuffers, FSoundQualityInfo& QualityInfo, TArray<uint8>& CompressedDataStore) const override
{
TRACE_CPUPROFILER_EVENT_SCOPE(FAudioFormatOpus::CookSurround);
check(Format == NAME_OPUS);
// For audio encoding purposes we want Full Band encoding with a 20ms frame size.
const uint32 kOpusSampleRate = GetMatchingOpusSampleRate(QualityInfo.SampleRate);
const int32 kOpusFrameSizeMs = 20;
// Calculate frame size required by Opus
const int32 kOpusFrameSizeSamples = (kOpusSampleRate * kOpusFrameSizeMs) / 1000;
const uint32 kSampleStride = SAMPLE_SIZE * QualityInfo.NumChannels;
const int32 kBytesPerFrame = kOpusFrameSizeSamples * kSampleStride;
// Number of silent samples to prepend that get removed after decoding.
const int32 kPrerollSkipCount = kOpusFrameSizeSamples * (80 / kOpusFrameSizeMs); // 80ms worth
TArray<TArray<uint8>> SrcBufferCopies;
SrcBufferCopies.AddDefaulted(SrcBuffers.Num());
for(int32 Index=0; Index<SrcBuffers.Num(); ++Index)
{
SrcBufferCopies[Index] = SrcBuffers[Index];
}
// Ensure that all channels are the same length
int32 SourceSize = -1;
for (int32 Index=0; Index<SrcBufferCopies.Num(); ++Index)
{
if (!Index)
{
SourceSize = SrcBufferCopies[Index].Num();
}
else
{
if (SourceSize != SrcBufferCopies[Index].Num())
{
return false;
}
}
}
if (SourceSize <= 0)
{
return false;
}
// Remember the actual number of samples
uint32 TrueSampleCount = SourceSize / SAMPLE_SIZE;
// Prepend the initial silence.
for (int32 Index = 0; Index < SrcBuffers.Num(); Index++)
{
SrcBufferCopies[Index].InsertZeroed(0, kPrerollSkipCount * SAMPLE_SIZE);
}
SourceSize += kPrerollSkipCount * SAMPLE_SIZE;
// Initialise the Opus multistream encoder
OpusMSEncoder* Encoder = NULL;
int32 EncError = 0;
int32 streams = 0;
int32 coupled_streams = 0;
// Mapping_family 1 as per https://www.rfc-editor.org/rfc/rfc7845.html#section-5.1.1.2
int32 mapping_family = 1;
TArray<uint8> mapping;
mapping.AddUninitialized(QualityInfo.NumChannels);
#if USE_UE_MEM_ALLOC
int32 EncSize = opus_multistream_surround_encoder_get_size(QualityInfo.NumChannels, mapping_family);
Encoder = (OpusMSEncoder*)FMemory::Malloc(EncSize);
EncError = opus_multistream_surround_encoder_init(Encoder, kOpusSampleRate, QualityInfo.NumChannels, mapping_family, &streams, &coupled_streams, mapping.GetData(), OPUS_APPLICATION_AUDIO);
#else
Encoder = opus_multistream_surround_encoder_create(kOpusSampleRate, QualityInfo.NumChannels, mapping_family, &streams, &coupled_streams, mapping.GetData(), OPUS_APPLICATION_AUDIO, &EncError);
#endif
if (EncError != OPUS_OK)
{
Destroy(Encoder);
return false;
}
int32 BitRate = GetBitRateFromQuality(QualityInfo);
opus_multistream_encoder_ctl(Encoder, OPUS_SET_BITRATE(BitRate));
// Get the number of pre-skip samples. These are to be skipped in addition to the initial silence.
int32 PreSkip = 0;
opus_multistream_encoder_ctl(Encoder, OPUS_GET_LOOKAHEAD(&PreSkip));
// We add silence to the end of the buffer as indicated by the pre-skip so we get this implicit
// decoder delay accounted for at the end. Otherwise the last samples may not be emitted by the decoder.
for (int32 Index = 0; Index < SrcBuffers.Num(); Index++)
{
SrcBufferCopies[Index].AddZeroed(PreSkip * SAMPLE_SIZE);
}
SourceSize += PreSkip * SAMPLE_SIZE;
// Create a buffer to store compressed data
CompressedDataStore.Empty();
FMemoryWriter CompressedData(CompressedDataStore);
int32 SrcBufferOffset = 0;
// Calc frame and sample count
int64 FramesToEncode = SourceSize / (kOpusFrameSizeSamples * SAMPLE_SIZE);
// Add another frame if Source does not divide into an equal number of frames
int32 NumSamplesInLastBlock = (SourceSize / SAMPLE_SIZE) % kOpusFrameSizeSamples;
if (NumSamplesInLastBlock != 0)
{
// The silence to pad the last block with is handled in the compression loop below.
++FramesToEncode;
}
check(QualityInfo.NumChannels <= MAX_uint8);
check(FramesToEncode <= MAX_uint32);
FOpusAudioInfo::FHeader Hdr;
Hdr.NumChannels = QualityInfo.NumChannels;
Hdr.SampleRate = QualityInfo.SampleRate;
Hdr.EncodedSampleRate = kOpusSampleRate;
Hdr.ActiveSampleCount = TrueSampleCount;
Hdr.NumEncodedFrames = (uint32) FramesToEncode;
Hdr.NumPreSkipSamples = PreSkip;
Hdr.NumSilentSamplesAtBeginning = kPrerollSkipCount;
Hdr.NumSilentSamplesAtEnd = NumSamplesInLastBlock ? kOpusFrameSizeSamples - NumSamplesInLastBlock : 0;
SerializeHeaderData(CompressedData, Hdr);
// Temporary storage for source data in an interleaved format
TArray<uint8> TempInterleavedSrc;
TempInterleavedSrc.AddUninitialized(kBytesPerFrame);
// Temporary storage with more than enough to store any compressed frame
TArray<uint8> TempCompressedData;
TempCompressedData.AddUninitialized(kBytesPerFrame);
while (SrcBufferOffset < SourceSize)
{
// Read a frames worth of data from the source and pack it into interleaved temporary storage
for (int32 SampleIndex = 0; SampleIndex < kOpusFrameSizeSamples; ++SampleIndex)
{
int32 CurrSrcOffset = SrcBufferOffset + SampleIndex*SAMPLE_SIZE;
int32 CurrInterleavedOffset = SampleIndex*kSampleStride;
if (CurrSrcOffset < SourceSize)
{
Copying //UE4/Dev-Core to //UE4/Dev-Main (Source: //UE4/Dev-Core @ 3125172) #lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 3053250 on 2016/07/18 by Steve.Robb TNot metafunction added. Change 3053252 on 2016/07/18 by Steve.Robb New TIsEnumClass trait. Change 3061345 on 2016/07/22 by Robert.Manuszewski Changing FMallocStomp::GetAllocationSize() to return the requested allocation size instead of the physical allocation size to make FMallocStomp work properly with FMallocPoisonProxy Change 3061377 on 2016/07/22 by Graeme.Thornton Added bStripAnimationDataOnDedicatedServer option to UAnimationSettings which will remove all compressed data from cooked server data. Disabled by default Change 3064592 on 2016/07/26 by Steven.Hutton Uploading repository files Change 3064595 on 2016/07/26 by Steven.Hutton Assign crashes to buggs based not just on Callstack but also based on Error message. Error messages have "data" masked out and are then compared to a table of error messages to find similar messages. Ensures are not currently filtered by error message. Change 3066046 on 2016/07/27 by Graeme.Thornton Better dedicated client/server class exclusion during cooking - Add class lists to cooker settings so they can be modified in the editor Change 3066077 on 2016/07/27 by Graeme.Thornton Move Paragon NeedsLoadForServer calls over to the new config based system Change 3066203 on 2016/07/27 by Chris.Wood CrashReportProcess logging and Slack reporting improvements to monitor disk space. [UE-31129] - Crash Report server need to alert on Slack when the PDB cache is full Change 3066276 on 2016/07/27 by Graeme.Thornton Move simple NeedsLoadForClient implementations over to new config based system Change 3068019 on 2016/07/28 by Graeme.Thornton Don't call ReleaseResources on UStaticMesh if we never render, and therefore never actually initialize the resources - Corrects some bad stats Change 3068218 on 2016/07/28 by Chris.Wood CrashReportProcess 1.1.18 passes BuildVersion to MinidumpDiagnostics [UE-31706] - Add new BuildVersion string to crash context and website Also modified command line log file ini settings to stop MDD stalling trying to sort and delete its logs. Change 3071665 on 2016/08/01 by Robert.Manuszewski Moving RemoveNamesFromMasterList from UEnum destructor to BeginDestroy to avoid potential issues when its package has already been destroyed. Change 3073388 on 2016/08/02 by Graeme.Thornton Invalidate string asset reference tags after finishing up loading of an async package Change 3073745 on 2016/08/02 by Robert.Manuszewski Disabling logging to memory in shipping by default. From now on FOutputDeviceMemory will be an opt-in for games. #jira FORT-27839 Change 3074866 on 2016/08/03 by Robert.Manuszewski PR #2650: Fixed a bug where newline escape sequence wasnt written to the pipe (Contributed by ozturkhakki) Change 3075128 on 2016/08/03 by Steve.Robb Static analysis fixes: error C2065: 'ThisOuterWorld': undeclared identifier Change 3075130 on 2016/08/03 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'LODLevel' Change 3075131 on 2016/08/03 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Owner' Change 3075235 on 2016/08/03 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'AnimToOperateOn' Change 3075248 on 2016/08/03 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'ParentProfile' Change 3075662 on 2016/08/03 by Steve.Robb Static analysis/buffer size fix: warning C28020: The expression '_Param_(7)>=sizeof(ICMP_ECHO_REPLY)+_Param_(4)+8' is not true at this call Change 3075668 on 2016/08/03 by Steve.Robb Static analysis fix: warning C6326: Potential comparison of a constant with another constant Change 3075679 on 2016/08/03 by Chris.Wood Added -NoTrimCallstack command line arg to MDD calls from CRP 1.1.19 [OR-26335] - 29.1 crash reporter generating reports with no callstacks / info New MDD has -NoTrimCallstack option to leave possibly irrelevant entires in the stack. Trimming is somewhat arbitrary and based on string matching. I'd rather see the whole thing. Change 3077070 on 2016/08/04 by Steve.Robb Dead array slack tracking code removed. Change 3077113 on 2016/08/04 by Steve.Robb TEnumAsByte is now deprecated for enum classes. All current uses fixed (which tidies up that code anyway). New FArchive::op<< for enum classes. Generated code now never uses TEnumAsByte for enum classes. Change 3077117 on 2016/08/04 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'DefaultSettings' Change 3078709 on 2016/08/05 by Steve.Robb FUNCTION_NO_NULL_RETURN_* macros added to statically annotate a function to say that it never returns a null pointer. TObjectIterator annotated to never return null. NewObject annotated to never return null. Change 3078836 on 2016/08/05 by Graeme.Thornton Silently skip creating exports from a package where the outer is also an export and has been filtered at runtime during loading Change 3082217 on 2016/08/09 by Steve.Robb Missing #include for FUniqueNetIdRepl added. Change 3083679 on 2016/08/10 by Chris.Wood CrashReportProcess performance improvements. CRP v1.1.22 [UE-34402] - Crash Reporter: Improve CRP performance by allowing multiple MDD instances [UE-34403] - Crash Reporter: CRP should throw away crashes when backlog is too large to avoid runaway Passing lock details to MDD on command line and managing multiple MDD tasks in CRP. Configurable values for range of queue sizes that cause us to throw away crashes. Change 3085362 on 2016/08/11 by Steve.Robb Rule-of-three fixes for FAIMessageObserver, to prevent accidents. From here: https://udn.unrealengine.com/questions/306507/tstaticarray-doesnt-call-destructor-on-elements-be.html Change 3085396 on 2016/08/11 by Steve.Robb Swap can now be configured via the TUseBitwiseSwap trait to not use Memswap, which can be less optimal for certain types. Change 3088840 on 2016/08/15 by Steve.Robb TRemoveReference moved to its own header. Change 3088858 on 2016/08/15 by Steve.Robb TDecay moved to its own header. Change 3088963 on 2016/08/15 by Steve.Robb Invoke function, for doing a generic call on a generic callable thing. Equivalent to std::invoke. Change 3089144 on 2016/08/15 by Steve.Robb Algo::Transform updated to use Invoke. Algorithm tests updated to test the new features. Change 3089147 on 2016/08/15 by Steve.Robb TLess and TGreater moved to their own headers and defaulted to void as a type-deducing version, as per std::. Change 3090243 on 2016/08/16 by Steve.Robb New Algo::Sort and Algo::SortBy algorithms. Change 3090387 on 2016/08/16 by Steve.Robb Improved bitwise swapping for Swap. See: https://udn.unrealengine.com/questions/306922/swap-is-painfully-slow.html Change 3090444 on 2016/08/16 by Steve.Robb Ptr+Size overloads removed after discussion - MakeArrayView should be used instead. Change 3090495 on 2016/08/16 by Steve.Robb Assert when FString::Mid is passed a negative count. #jira UE-18756 Change 3093455 on 2016/08/18 by Steve.Robb Debuggability and efficiency improvements to UScriptStruct::DeferCppStructOps. Change 3094476 on 2016/08/19 by Steve.Robb BOM removed from InvariantCulture.h. Change 3094697 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6237: (<zero> && <expression>) is always zero. <expression> is never evaluated and might have side effects. Change 3094702 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Interactor'. Change 3094715 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6385: Reading invalid data from 'Order': the readable size is '256' bytes, but '8160' bytes may be read. Change 3094737 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'OwnedComponent'. warning C28182: Dereferencing NULL pointer. 'Child' contains the same NULL value as 'AttachToComponent' did. Change 3094750 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Actor'. Change 3094768 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'LevelSequence'. warning C6011: Dereferencing NULL pointer 'Actor'. Change 3094774 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'CallFunctionNode'. Change 3094783 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'TargetPin'. Change 3094807 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'SourceClass'. Change 3094815 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'VarNode'. warning C6011: Dereferencing NULL pointer 'SourceClass'. Change 3094840 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'TunnelGraph'. warning C28182: Dereferencing NULL pointer. 'GraphNode' contains the same NULL value as 'SourceNode' did. Change 3094864 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'SpawnClassPin'. Change 3094880 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'PrevIfIndexMatchesStatement'. Change 3094886 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'SpawnBlueprintPin'. Change 3094903 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'K2Node'. Change 3094916 on 2016/08/19 by Steve.Robb Static analysis fix: Dereferencing NULL pointer 'CompilerContext'. Change 3094931 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'VariablePin'. Change 3094935 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'CurrentPin'. Change 3094943 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'Pin'. warning C28182: Dereferencing NULL pointer. 'Graph' contains the same NULL value as 'TargetGraph' did. Change 3094960 on 2016/08/19 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'LastOutPin'. Change 3095046 on 2016/08/19 by Steve.Robb Single parameter version of CastChecked tagged to never return null. Change 3095054 on 2016/08/19 by Steve.Robb Committed wrong version in CL# 3095046. Change 3095089 on 2016/08/19 by Steve.Robb Static analysis fixes: warning C6509: Invalid annotation: 'return' cannot be referenced in some contexts warning C6101: Returning uninitialized memory '*lpdwExitCode'. Change 3096035 on 2016/08/22 by Steve.Robb Fix for static lighting in pixel inspector. Change 3096039 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'World'. Change 3096045 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Actor'. Change 3096058 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'OtherPin'. Change 3096059 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'MainMesh'. Change 3096066 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'SourceType'. Change 3096070 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'LastPushStatement'. Change 3096074 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'OriginalDataTableInPin'. Change 3096075 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'CurrentPin'. Change 3096081 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'RunningPlatformData'. Change 3096156 on 2016/08/22 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'BP'. warning C6011: Dereferencing NULL pointer 'Object'. Change 3096308 on 2016/08/22 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'TopMipData'. warning C6011: Dereferencing NULL pointer 'MipCoverageData[0]'. Change 3096315 on 2016/08/22 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'OldParent'. warning C6011: Dereferencing NULL pointer 'TestExecutionInfo'. Change 3096318 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'OwnerClass'. Change 3096322 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'StaticMeshInstanceData'. Change 3096337 on 2016/08/22 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'Pin'. warning C6011: Dereferencing NULL pointer 'SpawnVarPin'. Change 3096345 on 2016/08/22 by Steve.Robb Static analysis fixes: warning C6246: Local declaration of 'NumTris' hides declaration of the same name in outer scope. Change 3096356 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'InWorld'. Change 3096387 on 2016/08/22 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'ExpressionPreviewMaterial'. warning C6011: Dereferencing NULL pointer 'MaterialNode->MaterialExpression'. Change 3096400 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'FunctionInputs'. Change 3096413 on 2016/08/22 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'LODPackage' contains the same NULL value as 'AssetsOuter' did. Change 3096416 on 2016/08/22 by Steve.Robb Static analysis fixes: warning C6237: (<zero> && <expression>) is always zero. <expression> is never evaluated and might have side effects. Change 3096423 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'RedirectorRefs.Redirector'. Change 3096439 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'NewObject'. Change 3096446 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'BaseClass'. Change 3096454 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'OldSkeleton'. Change 3096464 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'MyNode'. Change 3096469 on 2016/08/22 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'VRInteractor'. Change 3097559 on 2016/08/23 by Steve.Robb Alternate fix to CL# 3096439. Change 3097583 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'SourceCategoryEnum'. warning C6011: Dereferencing NULL pointer 'CurrentWorld'. Change 3097584 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'LocalizationTarget'. Change 3097585 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C28182: Dereferencing NULL pointer. 'VariableSetNode' contains the same NULL value as 'AssignmentNode' did. warning C6011: Dereferencing NULL pointer 'FirstNativeClass'. Change 3097588 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'OutputObjClass'. Change 3097589 on 2016/08/23 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'Term' contains the same NULL value as 'RValueTerm' did. Change 3097591 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Schema'. Change 3097597 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'LayerInfo'. Change 3097598 on 2016/08/23 by Steve.Robb Const-correctness fix for ILandscapeEditorModule::GetHeightmapFormatByExtension and ILandscapeEditorModule::GetWeightmapFormatByExtension. Change 3097600 on 2016/08/23 by Steve.Robb Fix for incorrect null check. Change 3097605 on 2016/08/23 by Steve.Robb Spurious static analysis fix: warning C6011: Dereferencing NULL pointer 'TexDataPtr'. Bug filed here: https://connect.microsoft.com/VisualStudio/feedback/details/3078125 Change 3097609 on 2016/08/23 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'ObjClass' contains the same NULL value as 'BaseClass' did. Change 3097613 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'InEdGraph'. Change 3097620 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'ThisScalableFloat'. Change 3097627 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'AnimBlueprint'. Change 3097629 on 2016/08/23 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'Pin' contains the same NULL value as 'PoseNet' did. Change 3097631 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'IPOverlayInfo.Brush'. Change 3097634 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Survey'. Change 3097639 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'Settings'. Change 3097650 on 2016/08/23 by Steve.Robb Alternate fix for CL# 3097597. Change 3097725 on 2016/08/23 by Steve.Robb Spurious static analysis fix: warning C6011: Dereferencing NULL pointer 'BodySetup'. Change 3097764 on 2016/08/23 by Steve.Robb Spurious static analysis fix: warning C28182: Dereferencing NULL pointer. 'FoundMode' contains the same NULL value as 'ElementType * FoundMode=LoopModes.FindByPredicate(<lambda>)' did. Change 3097770 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Triangle'. Change 3097775 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'CurGroup'. Change 3097796 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'SourceComponent'. Change 3097797 on 2016/08/23 by Steve.Robb Spurious static analysis fix: warning C6011: Dereferencing NULL pointer 'HitComponent'. Change 3097843 on 2016/08/23 by Steve.Robb Spurious static analysis fix: Dereferencing NULL pointer. 'MatchingNewPin' contains the same NULL value as 'UEdGraphPin ** MatchingNewPin=this->Pins.FindByPredicate(<lambda>)' did. Change 3097864 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'ObjectClass'. warning C6011: Dereferencing NULL pointer 'Client'. Change 3097871 on 2016/08/23 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'SMLightingMesh->StaticMesh' contains the same NULL value as 'StaticMesh' did. Change 3098015 on 2016/08/23 by Steve.Robb Alternative fix for CL# 3094864. Change 3098024 on 2016/08/23 by Steve.Robb Alternative fix for CL# 3094943. Change 3098052 on 2016/08/23 by Steve.Robb Alternative fix for CL# 3094886. Change 3098080 on 2016/08/23 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'PrimitiveComponent' contains the same NULL value as 'ReplacementComponent' did. Change 3098102 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'IndexTermPtr'. Change 3098148 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'Node'. warning C6011: Dereferencing NULL pointer 'OldNode'. warning C6011: Dereferencing NULL pointer 'LinkedPin'. warning C6011: Dereferencing NULL pointer 'RootNode'. Change 3098156 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'BTGraphNode'. Change 3098176 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'NewSection'. Change 3098182 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Sprite'. Change 3098197 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'Node'. Coding standards fixes. Change 3098202 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'ExistingEventNode'. Change 3098208 on 2016/08/23 by Steve.Robb Static analysis fixes: warning C28182: Dereferencing NULL pointer. 'Graph' contains the same NULL value as 'GraphNew' did. warning C28182: Dereferencing NULL pointer. 'GoodGraph' contains the same NULL value as 'GraphNew' did. Change 3098229 on 2016/08/23 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Property'. Change 3099188 on 2016/08/24 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'SharedBaseClass'. Change 3099195 on 2016/08/24 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'NodeProperty'. Change 3099205 on 2016/08/24 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'VarDesc'. Change 3099228 on 2016/08/24 by Steve.Robb Spurious static analysis fix: warning C28182: Dereferencing NULL pointer. 'Node' contains the same NULL value as 'ParentNode' did. Change 3099539 on 2016/08/24 by Steve.Robb Spurious static analysis fixes: warning C6011: Dereferencing NULL pointer 'InBlueprint'. warning C28182: Dereferencing NULL pointer. 'TestObj' contains the same NULL value as 'TestOuter' did. https://connect.microsoft.com/VisualStudio/feedback/details/3082362 https://connect.microsoft.com/VisualStudio/feedback/details/3082622 Change 3099546 on 2016/08/24 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'OldNode'. Change 3099561 on 2016/08/24 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'ReferencedObject'. Change 3099571 on 2016/08/24 by Steve.Robb Static analysis fix: Dereferencing NULL pointer. 'ObjClass' contains the same NULL value as 'CommonBaseClass' did. Change 3099600 on 2016/08/24 by Steve.Robb Static analysis fix: warning C6385: Reading invalid data from 'this->Packages': the readable size is '24' bytes, but '32' bytes may be read. warning C6385: Reading invalid data from 'Diff.ObjectSets': the readable size is '24' bytes, but '32' bytes may be read. warning C6386: Buffer overrun while writing to 'Objects': the writable size is '24' bytes, but '32' bytes might be written. Change 3099912 on 2016/08/24 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'SharedBaseClass'. Change 3099923 on 2016/08/24 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'ThumbnailInfo'. Change 3100977 on 2016/08/25 by Steve.Robb Static analysis fixes: warning C6001: Using uninitialized memory '*VectorRef'. warning C6001: Using uninitialized memory '*PointRef'. warning C6001: Using uninitialized memory '*PolyRef'. Coding standard fixes. Change 3100985 on 2016/08/25 by Steve.Robb Static analyis fix: warning C6011: Dereferencing NULL pointer 'SpawnClassPin'. Change 3100987 on 2016/08/25 by Steve.Robb Static analysis fixes: warning C28183: 'Resources.BitmapHandle' could be '0', and is a copy of the value found in 'CreateDIBSection()`829': this does not adhere to the specification for the function 'SelectObject'. warning C6387: '_Param_(4)' could be '0': this does not adhere to the specification for the function 'CreateDIBSection'. Change 3100992 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6287: Redundant code: the left and right sub-expressions are identical. Change 3101000 on 2016/08/25 by Steve.Robb Static analysis fixes: warning C6001: Using uninitialized memory 'tmpMemReq'. warning C6001: Using uninitialized memory 'TmpCreateInfo'. Change 3101004 on 2016/08/25 by Steve.Robb warning C28182: Dereferencing NULL pointer. 'FoliageActor' contains the same NULL value as 'Actor' did. Change 3101009 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'StaticMeshComponent'. Change 3101115 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Canvas'. Change 3101120 on 2016/08/25 by Steve.Robb Fixes to previous fixes. Change 3101128 on 2016/08/25 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'Stream'. Change 3101281 on 2016/08/25 by Steve.Robb Static analysis fixes: warning C6262: Function uses '99256' bytes of stack: exceeds /analyze:stacksize '81940'. Consider moving some data to heap. warning C6001: Using uninitialized memory 'Pixel'. Change 3101292 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'BulkDataPointer'. Change 3101299 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'UnrealMaterial'. Change 3101300 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'AssetObject'. Change 3101304 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'MeshRootNode'. Change 3101311 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Cluster'. Change 3101323 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'StartNode'. Change 3101329 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Object'. Change 3101333 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'ArrayRef'. Change 3101339 on 2016/08/25 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'ImportData'. warning C6011: Dereferencing NULL pointer 'CurveToImport'. Change 3101485 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'ObjectProperty'. Change 3101583 on 2016/08/25 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'UserDefinedStruct'. Change 3105721 on 2016/08/30 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'SpawnClassPin'. Change 3105724 on 2016/08/30 by Steven.Hutton Change users page to more responsive paginated version. Change 3105725 on 2016/08/30 by Steven.Hutton Added field for crash processor failed Change 3105786 on 2016/08/30 by Steve.Robb Reintroduced missing operator<< for enum classes. Change 3105803 on 2016/08/30 by Steve.Robb Removal of obsolete code and state. PrepareCppStructOps() has several unreachable blocks, one of which sets UScriptStruct::bCppStructOpsFromBaseClass which is otherwise never true, so it can be removed too. Change 3106251 on 2016/08/30 by Steve.Robb Switch static analysis node to build editor instead of just the engine. Change 3107556 on 2016/08/31 by Steven.Hutton Added build version data from CRP to DB as part of add crash #rb none Change 3107557 on 2016/08/31 by Steven.Hutton Passed build version data to CRW through crash description #rb none Change 3107634 on 2016/08/31 by Graeme.Thornton Only accept "log=<filename>" and "abslog=<filename>" command line values if the filename has a "log" or "txt" extension #jira UE-20147 Change 3107797 on 2016/08/31 by Steve.Robb Fix for UHT debugging manifest, after paths changed in CL# 3088416. Change 3107964 on 2016/08/31 by Steve.Robb TCString::Strfind renamed to TCString::Strifind, as it is case-insensitive. New case-sensitive TCString::Strfind added, based on GitHub PR #2453. Change 3108023 on 2016/08/31 by Steve.Robb Removal of test code which no longer compiles now that we emit errors on skipped preprocessor blocks. Change 3108160 on 2016/08/31 by Steven.Hutton Update to add new filter to website front page #rb none Change 3109556 on 2016/09/01 by Steven.Hutton Fixing compile warning #rb none Change 3110001 on 2016/09/01 by Steve.Robb PR #2468: Fix for UnrealHeaderTool TArray<TScriptInterface<>> UFUNCTION parameters (Contributed by UnrealEverything) Change 3111835 on 2016/09/02 by Steve.Robb Enforce uint8 on UENUM() enum classes. #jira UE-35224 Change 3111867 on 2016/09/02 by Steve.Robb Static analysis fix: warning C6236: (<expression> || <non-zero constant>) is always a non-zero constant. Change 3111880 on 2016/09/02 by Steve.Robb Static analysis fixes: warning C6386: Buffer overrun while writing to 'Views': the writable size is 'ShaderBindings.ResourceViews.public: int __cdecl TArray<class TSlateD3DTypedShaderParameter<struct ID3D11ShaderResourceView> *,class FDefaultAllocator>::Num(void)const ()*8' bytes, but '16' bytes might be written. warning C6386: Buffer overrun while writing to 'ConstantBuffers': the writable size is 'ShaderBindings.ConstantBuffers.public: int __cdecl TArray<class TSlateD3DTypedShaderParameter<struct ID3D11Buffer> *,class FDefaultAllocator>::Num(void)const ()*8' bytes, but '16' bytes might be written. Change 3111886 on 2016/09/02 by Steve.Robb Static analysis fix: warning C6386: Buffer overrun while writing to 'DistortionMeshIndices': the writable size is 'NumIndices*2' bytes, but '4' bytes might be written. Change 3112025 on 2016/09/02 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'pInputProcessParameters'. warning C6011: Dereferencing NULL pointer 'pOutputProcessParameters'. Change 3112051 on 2016/09/02 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Command'. Change 3112066 on 2016/09/02 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'CurNetDriver'. Change 3112093 on 2016/09/02 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'byteArray'. Change 3112110 on 2016/09/02 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'PersistentParty'. Change 3112123 on 2016/09/02 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'CurDriver'. warning C6011: Dereferencing NULL pointer 'CurNetDriver'. warning C6011: Dereferencing NULL pointer 'CurWorld'. Change 3112157 on 2016/09/02 by Steve.Robb Static analysis fixes: warning C6011: Dereferencing NULL pointer 'UnitTest'. Change 3112283 on 2016/09/02 by Steve.Robb Static analysis fixes: warning C6244: Local declaration of 'None' hides previous declaration at line '173' of 'netcodeunittest.h'. Change 3113455 on 2016/09/05 by Chris.Wood CRP performance improvements (v1.1.25) Change 3113468 on 2016/09/05 by Steve.Robb Reverting unnecessary merge in CL# 3112464. Change 3113508 on 2016/09/05 by Steve.Robb Static analysis fix: warning C6031: Return value ignored: 'CoCreateGuid'. Change 3113588 on 2016/09/05 by Steve.Robb Static analysis fix: warning C6244: Local declaration of 'hInstance' hides previous declaration Change 3113863 on 2016/09/06 by Steve.Robb Fix for this error: Could not find a part of the path 'D:\Build\++UE4+Dev-Core+Compile\Sync\Engine\Plugins\2D\Paper2D\Binaries\Win64\UE4Editor.modules'. Change 3113864 on 2016/09/06 by Steve.Robb Misc static analysis fixes for VS2015 Update 2. Change 3113918 on 2016/09/06 by Ben.Marsh Explicitly check for version manifest existing before trying to delete it, rather than swallowing the exception. Change 3114293 on 2016/09/06 by Steve.Robb Static analysis fixes for Visual Studio Update 2. Change 3115732 on 2016/09/07 by Steve.Robb Static analysis fix: warning C6262: Function uses '121180' bytes of stack: exceeds /analyze:stacksize '81940'. Consider moving some data to heap. Change 3115754 on 2016/09/07 by Steve.Robb GObjectArrayForDebugVisualizers init order fix. Removal of obsolete FName visualizer helper code. Change 3115774 on 2016/09/07 by Steve.Robb Fix for ICE by moving static variables into their own file and removing const return types. #jira UE-35597 Change 3116061 on 2016/09/07 by Steve.Robb Redundant LOCTEXT_NAMESPACE removed - was missed in CL# 3115774. Change 3117478 on 2016/09/08 by Steve.Robb Static analysis fixes in third party code, using a new macro-based system. Change 3119152 on 2016/09/09 by Steve.Robb TArray::RemoveAt and RemoveAtSwap with a bool Count is now a compile error. Change 3119200 on 2016/09/09 by Steve.Robb Fix for destructors not being called in TSparseArray move assignment. Change 3119568 on 2016/09/09 by Steve.Robb Fix for TSparseArray visualizer. Change 3119591 on 2016/09/09 by Steve.Robb New MakeShared function which allocates the object and reference controller in a single block. Change 3120281 on 2016/09/09 by Steve.Robb Fix for ICE on static analysis build. #jira UE-35596 Change 3120786 on 2016/09/12 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'SavedGame'. Change 3120787 on 2016/09/12 by Steve.Robb Removal of TEnumAsByte on enum classes. Change 3120789 on 2016/09/12 by Steve.Robb Static analysis fixes: warning C6385: Reading invalid data from 'D3D11X_CERAM_OFFSET_BY_SET_STAGE': the readable size is '28' bytes, but '64' bytes may be read. warning C6101: Returning uninitialized memory '*pDescriptorDst'. A successful path through the function does not set the named _Out_ parameter. Change 3121234 on 2016/09/12 by Steve.Robb Unused ToBuildInfoString function declaration removed. Change 3122616 on 2016/09/13 by Steve.Robb Static analysis fix: warning C6011: Dereferencing NULL pointer 'Compiler'. Change 3123070 on 2016/09/13 by Steve.Robb Static analysis fix: warning C28182: Dereferencing NULL pointer. 'top' contains the same NULL value as 'edge' did. [CL 3126145 by Robert Manuszewski in Main branch]
2016-09-15 00:21:42 -04:00
check(QualityInfo.NumChannels <= 8); // Static analysis fix: warning C6385: Reading invalid data from 'Order': the readable size is '256' bytes, but '8160' bytes may be read.
for (uint32 ChannelIndex = 0; ChannelIndex < QualityInfo.NumChannels; ++ChannelIndex)
{
// Interleave the channels in the Vorbis format, so that the correct channel is used for LFE
int32 OrderedChannelIndex = VorbisChannelInfo::Order[QualityInfo.NumChannels - 1][ChannelIndex];
int32 CurrInterleavedIndex = CurrInterleavedOffset + ChannelIndex*SAMPLE_SIZE;
// Copy both bytes that make up a single sample
TempInterleavedSrc[CurrInterleavedIndex] = SrcBufferCopies[OrderedChannelIndex][CurrSrcOffset];
TempInterleavedSrc[CurrInterleavedIndex + 1] = SrcBufferCopies[OrderedChannelIndex][CurrSrcOffset + 1];
}
}
else
{
// Zero the rest of the temp buffer to make it an exact frame
FMemory::Memzero(TempInterleavedSrc.GetData() + CurrInterleavedOffset, kBytesPerFrame - CurrInterleavedOffset);
SampleIndex = kOpusFrameSizeSamples;
}
}
int32 CompressedLength = opus_multistream_encode(Encoder, (const opus_int16*)(TempInterleavedSrc.GetData()), kOpusFrameSizeSamples, TempCompressedData.GetData(), TempCompressedData.Num());
if (CompressedLength < 0)
{
const char* ErrorStr = opus_strerror(CompressedLength);
UE_LOG(LogAudio, Warning, TEXT("Failed to encode: [%d] %s"), CompressedLength, ANSI_TO_TCHAR(ErrorStr));
Destroy(Encoder);
CompressedDataStore.Empty();
return false;
}
else
{
// Store frame length and copy compressed data before incrementing pointers
check(CompressedLength < MAX_uint16);
SerialiseFrameData(CompressedData, TempCompressedData.GetData(), CompressedLength);
SrcBufferOffset += kOpusFrameSizeSamples * SAMPLE_SIZE;
}
}
Destroy(Encoder);
return CompressedDataStore.Num() > 0;
}
int32 Recompress(FName Format, const TArray<uint8>& SrcBuffer, FSoundQualityInfo& QualityInfo, TArray<uint8>& OutBuffer) const override
{
check(Format == NAME_OPUS);
FOpusAudioInfo AudioInfo;
// Cannot quality preview multichannel sounds
if( QualityInfo.NumChannels > 2 )
{
return 0;
}
TArray<uint8> CompressedDataStore;
if( !Cook( Format, SrcBuffer, QualityInfo, CompressedDataStore ) )
{
return 0;
}
// Parse the opus header for the relevant information
if( !AudioInfo.ReadCompressedInfo( CompressedDataStore.GetData(), CompressedDataStore.Num(), &QualityInfo ) )
{
return 0;
}
// Decompress all the sample data
OutBuffer.Empty(QualityInfo.SampleDataSize);
OutBuffer.AddZeroed(QualityInfo.SampleDataSize);
AudioInfo.ExpandFile( OutBuffer.GetData(), &QualityInfo );
return CompressedDataStore.Num();
}
int32 GetMinimumSizeForInitialChunk(FName Format, const TArray<uint8>& SrcBuffer) const override
{
return FOpusAudioInfo::FHeader::HeaderSize();
}
bool SplitDataForStreaming(const TArray<uint8>& SrcBuffer, TArray<TArray<uint8>>& OutBuffers, const int32 MaxInitialChunkSize, const int32 MaxChunkSize) const override
{
// This should not be called if we require a streaming seek-table.
if (!ensure(!RequiresStreamingSeekTable()))
{
return false;
}
if (SrcBuffer.Num() == 0)
{
return false;
}
uint32 ReadOffset = 0;
uint32 WriteOffset = 0;
uint32 ProcessedFrames = 0;
const uint8* LockedSrc = SrcBuffer.GetData();
FOpusAudioInfo::FHeader Hdr;
if (!FOpusAudioInfo::ParseHeader(Hdr, ReadOffset, LockedSrc, SrcBuffer.Num()))
{
return false;
}
// Should always be able to store basic info in a single chunk
check(ReadOffset - WriteOffset <= (uint32)MaxInitialChunkSize);
int32 ChunkSize = MaxInitialChunkSize;
while (ProcessedFrames < Hdr.NumEncodedFrames)
{
uint16 FrameSize = *((uint16*)(LockedSrc + ReadOffset));
if ( (ReadOffset + sizeof(uint16) + FrameSize) - WriteOffset >= ChunkSize)
{
WriteOffset += AddDataChunk(OutBuffers, LockedSrc + WriteOffset, ReadOffset - WriteOffset);
}
ReadOffset += sizeof(uint16) + FrameSize;
ProcessedFrames++;
ChunkSize = MaxChunkSize;
}
if (WriteOffset < ReadOffset)
{
WriteOffset += AddDataChunk(OutBuffers, LockedSrc + WriteOffset, ReadOffset - WriteOffset);
}
return true;
}
bool RequiresStreamingSeekTable() const override
{
return true;
}
bool ExtractSeekTableForStreaming(TArray<uint8>& InOutBuffer, IAudioFormat::FSeekTable& OutSeektable) const override
{
// This should only be called if we require a streaming seek-table.
if (!ensure(RequiresStreamingSeekTable()))
{
return false;
}
FOpusAudioInfo::FHeader Hdr;
uint32 CurrentOffset = 0;
uint8* Data = InOutBuffer.GetData();
if (!FOpusAudioInfo::ParseHeader(Hdr, CurrentOffset, Data, InOutBuffer.Num()))
{
return false;
}
Data += CurrentOffset;
int32 NumFrames = Hdr.NumEncodedFrames;
OutSeektable.Offsets.SetNum(NumFrames);
OutSeektable.Times.SetNum(NumFrames);
const uint16 kOpusSampleRate = 48000;
const int32 kOpusFrameSizeMs = 20;
const int32 kOpusFrameSizeSamples = (kOpusSampleRate * kOpusFrameSizeMs) / 1000;
uint64 SamplePos = 0;
uint32 CompressedPos = CurrentOffset;
for(int32 i=0; i<NumFrames; ++i)
{
OutSeektable.Times[i] = SamplePos;
OutSeektable.Offsets[i] = CompressedPos;
uint16 FrameSize = *reinterpret_cast<const uint16*>(Data);
Data += FrameSize + sizeof(uint16);
CompressedPos += FrameSize + sizeof(uint16);
SamplePos += kOpusFrameSizeSamples;
}
return true;
}
int32 GetBitRateFromQuality(FSoundQualityInfo& QualityInfo) const
{
const int32 kMinBpsPerChannel = 16000;
const int32 kMaxBpsPerChannel = 96000;
const int32 kQuality = QualityInfo.Quality < 1 ? 1 : QualityInfo.Quality > 100 ? 100 : QualityInfo.Quality;
int32 Bps = (int32) FMath::GetMappedRangeValueClamped(FVector2f(1, 100), FVector2f(kMinBpsPerChannel, kMaxBpsPerChannel), (float)kQuality);
Bps *= QualityInfo.NumChannels;
return Bps;
}
uint32 GetMatchingOpusSampleRate(uint32 InRate) const
{
if (InRate <= 8000)
{
return 8000;
}
else if (InRate <= 12000)
{
return 12000;
}
if (InRate <= 16000)
{
return 16000;
}
if (InRate <= 24000)
{
return 24000;
}
return 48000;
}
void SerializeHeaderData(FMemoryWriter& CompressedData, FOpusAudioInfo::FHeader& InHeader) const
{
InHeader.Version = 0;
FMemory::Memcpy(InHeader.Identifier, FOpusAudioInfo::FHeader::OPUS_ID, 8);
CompressedData.Serialize(InHeader.Identifier, 8);
CompressedData.Serialize(&InHeader.Version, sizeof(uint8));
CompressedData.Serialize(&InHeader.NumChannels, sizeof(uint8));
CompressedData.Serialize(&InHeader.SampleRate, sizeof(uint32));
CompressedData.Serialize(&InHeader.EncodedSampleRate, sizeof(uint32));
CompressedData.Serialize(&InHeader.ActiveSampleCount, sizeof(uint64));
CompressedData.Serialize(&InHeader.NumEncodedFrames, sizeof(uint32));
CompressedData.Serialize(&InHeader.NumPreSkipSamples, sizeof(int32));
CompressedData.Serialize(&InHeader.NumSilentSamplesAtBeginning, sizeof(int32));
CompressedData.Serialize(&InHeader.NumSilentSamplesAtEnd, sizeof(int32));
}
void SerialiseFrameData(FMemoryWriter& CompressedData, uint8* FrameData, uint16 FrameSize) const
{
CompressedData.Serialize(&FrameSize, sizeof(uint16));
CompressedData.Serialize(FrameData, FrameSize);
}
void Destroy(OpusEncoder* Encoder) const
{
#if USE_UE_MEM_ALLOC
FMemory::Free(Encoder);
#else
opus_encoder_destroy(Encoder);
#endif
}
void Destroy(OpusMSEncoder* Encoder) const
{
#if USE_UE_MEM_ALLOC
FMemory::Free(Encoder);
#else
opus_multistream_encoder_destroy(Encoder);
#endif
}
/**
* Adds a new chunk of data to the array
*
* @param OutBuffers Array of buffers to add to
* @param ChunkData Pointer to chunk data
* @param ChunkSize How much data to write
* @return How many bytes were written
*/
int32 AddDataChunk(TArray<TArray<uint8>>& OutBuffers, const uint8* ChunkData, int32 ChunkSize) const
{
TArray<uint8>& NewBuffer = OutBuffers.AddDefaulted_GetRef();
NewBuffer.Empty(ChunkSize);
NewBuffer.AddUninitialized(ChunkSize);
FMemory::Memcpy(NewBuffer.GetData(), ChunkData, ChunkSize);
return ChunkSize;
}
};
/**
* Module for opus audio compression
*/
static IAudioFormat* Singleton = NULL;
class FAudioPlatformOpusModule : public IAudioFormatModule
{
public:
virtual ~FAudioPlatformOpusModule()
{
delete Singleton;
Singleton = NULL;
}
virtual IAudioFormat* GetAudioFormat()
{
if (!Singleton)
{
Singleton = new FAudioFormatOpus();
}
return Singleton;
}
};
IMPLEMENT_MODULE( FAudioPlatformOpusModule, AudioFormatOpus);