├── .gitignore ├── FrameCapturer ├── Assets │ ├── FrameCapturerPackaging.cs │ ├── FrameCapturerPackaging.cs.meta │ ├── FrameRecorderTest.unity │ ├── FrameRecorderTest.unity.meta │ ├── StreamingAssets.meta │ ├── StreamingAssets │ │ ├── UTJ.meta │ │ └── UTJ │ │ │ ├── FrameCapturer.meta │ │ │ └── FrameCapturer │ │ │ ├── License.txt │ │ │ └── License.txt.meta │ ├── TestData.meta │ ├── TestData │ │ ├── Animations.meta │ │ ├── Animations │ │ │ ├── Camera1.anim │ │ │ ├── Camera1.anim.meta │ │ │ ├── CameraRig.controller │ │ │ └── CameraRig.controller.meta │ │ ├── Raymarching.meta │ │ ├── Raymarching │ │ │ ├── Raymarcher.cs │ │ │ ├── Raymarcher.cs.meta │ │ │ ├── Raymarcher.mat │ │ │ ├── Raymarcher.mat.meta │ │ │ ├── Raymarcher.shader │ │ │ ├── Raymarcher.shader.meta │ │ │ ├── TestStandard.mat │ │ │ ├── TestStandard.mat.meta │ │ │ ├── distance_functions.cginc │ │ │ ├── distance_functions.cginc.meta │ │ │ ├── foundation.cginc │ │ │ └── foundation.cginc.meta │ │ ├── Sounds.meta │ │ ├── Sounds │ │ │ ├── demo.mp3 │ │ │ └── demo.mp3.meta │ │ ├── Utilities.meta │ │ └── Utilities │ │ │ ├── CameraControl.cs │ │ │ ├── CameraControl.cs.meta │ │ │ ├── FrameRateCounter.cs │ │ │ ├── FrameRateCounter.cs.meta │ │ │ ├── FrameRateCounter.prefab │ │ │ └── FrameRateCounter.prefab.meta │ ├── UTJ.meta │ └── UTJ │ │ ├── FrameCapturer.meta │ │ ├── FrameCapturer │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── AudioEncoderConfigDrawer.cs │ │ │ ├── AudioEncoderConfigDrawer.cs.meta │ │ │ ├── AudioRecorderEditor.cs │ │ │ ├── AudioRecorderEditor.cs.meta │ │ │ ├── GBufferRecorderEditor.cs │ │ │ ├── GBufferRecorderEditor.cs.meta │ │ │ ├── Misc.meta │ │ │ ├── Misc │ │ │ │ ├── BoolDrawer.cs │ │ │ │ ├── BoolDrawer.cs.meta │ │ │ │ ├── DataPathDrawer.cs │ │ │ │ └── DataPathDrawer.cs.meta │ │ │ ├── MovieEncoderConfigDrawer.cs │ │ │ ├── MovieEncoderConfigDrawer.cs.meta │ │ │ ├── MovieRecorderEditor.cs │ │ │ ├── MovieRecorderEditor.cs.meta │ │ │ ├── RecorderBaseEditor.cs │ │ │ └── RecorderBaseEditor.cs.meta │ │ ├── Plugins.meta │ │ ├── Plugins │ │ │ ├── x86.meta │ │ │ ├── x86 │ │ │ │ └── fccore.dll.meta │ │ │ ├── x86_64.meta │ │ │ └── x86_64 │ │ │ │ ├── fccore.bundle.meta │ │ │ │ ├── fccore.bundle │ │ │ │ ├── Contents.meta │ │ │ │ └── Contents │ │ │ │ │ ├── Info.plist.meta │ │ │ │ │ ├── MacOS.meta │ │ │ │ │ └── MacOS │ │ │ │ │ └── fccore.meta │ │ │ │ ├── fccore.dll.meta │ │ │ │ └── libfccore.so.meta │ │ ├── Scripts.meta │ │ ├── Scripts │ │ │ ├── AudioRecorder.cs │ │ │ ├── AudioRecorder.cs.meta │ │ │ ├── Encoder.meta │ │ │ ├── Encoder │ │ │ │ ├── AudioEncoder.cs │ │ │ │ ├── AudioEncoder.cs.meta │ │ │ │ ├── EncoderBase.cs │ │ │ │ ├── EncoderBase.cs.meta │ │ │ │ ├── ExrEncoder.cs │ │ │ │ ├── ExrEncoder.cs.meta │ │ │ │ ├── FlacEncoder.cs │ │ │ │ ├── FlacEncoder.cs.meta │ │ │ │ ├── GifEncoder.cs │ │ │ │ ├── GifEncoder.cs.meta │ │ │ │ ├── MP4Encoder.cs │ │ │ │ ├── MP4Encoder.cs.meta │ │ │ │ ├── MovieEncoder.cs │ │ │ │ ├── MovieEncoder.cs.meta │ │ │ │ ├── OggEncoder.cs │ │ │ │ ├── OggEncoder.cs.meta │ │ │ │ ├── PngEncoder.cs │ │ │ │ ├── PngEncoder.cs.meta │ │ │ │ ├── WaveEncoder.cs │ │ │ │ ├── WaveEncoder.cs.meta │ │ │ │ ├── WebMEncoder.cs │ │ │ │ ├── WebMEncoder.cs.meta │ │ │ │ ├── fcAPI.cs │ │ │ │ └── fcAPI.cs.meta │ │ │ ├── GBufferRecorder.cs │ │ │ ├── GBufferRecorder.cs.meta │ │ │ ├── Misc.meta │ │ │ ├── Misc │ │ │ │ ├── Bool.cs │ │ │ │ ├── Bool.cs.meta │ │ │ │ ├── DataPath.cs │ │ │ │ └── DataPath.cs.meta │ │ │ ├── MovieRecorder.cs │ │ │ ├── MovieRecorder.cs.meta │ │ │ ├── RecorderBase.cs │ │ │ └── RecorderBase.cs.meta │ │ ├── Shaders.meta │ │ └── Shaders │ │ │ ├── CopyFrameBuffer.shader │ │ │ └── CopyFrameBuffer.shader.meta │ │ ├── FrameCapturerExample.meta │ │ └── FrameCapturerExample │ │ ├── Animation.meta │ │ ├── Animation │ │ ├── Camera.anim │ │ ├── Camera.anim.meta │ │ ├── CameraRig.controller │ │ ├── CameraRig.controller.meta │ │ ├── Sphere.anim │ │ ├── Sphere.anim.meta │ │ ├── Sphere.controller │ │ └── Sphere.controller.meta │ │ ├── Materials.meta │ │ ├── Materials │ │ ├── Test1.mat │ │ ├── Test1.mat.meta │ │ ├── Test2.mat │ │ ├── Test2.mat.meta │ │ ├── Test3.mat │ │ ├── Test3.mat.meta │ │ ├── Test4.mat │ │ └── Test4.mat.meta │ │ ├── Prefabs.meta │ │ ├── Prefabs │ │ ├── CameraRig.prefab │ │ ├── CameraRig.prefab.meta │ │ ├── Root.prefab │ │ └── Root.prefab.meta │ │ ├── Test.unity │ │ ├── Test.unity.meta │ │ ├── TestOffscreen.unity │ │ ├── TestOffscreen.unity.meta │ │ ├── Textures.meta │ │ └── Textures │ │ ├── RenderTarget.renderTexture │ │ └── RenderTarget.renderTexture.meta └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── NavMeshProjectSettings.asset │ ├── NetworkManager.asset │ ├── Physics2DSettings.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityAdsSettings.asset │ └── UnityConnectSettings.asset ├── LICENSE.txt ├── Plugin ├── CMakeLists.txt ├── NatvisFile.natvis ├── Test │ ├── CMakeLists.txt │ ├── ConvertTest.cpp │ ├── ExrTest.cpp │ ├── FlacTest.cpp │ ├── GifTest.cpp │ ├── GraphicsDevice.cpp │ ├── MP4Test.cpp │ ├── MemoryLeakBuster.cpp │ ├── OggTest.cpp │ ├── PngTest.cpp │ ├── Test.cpp │ ├── Test.vcxproj │ ├── TestCommon.cpp │ ├── TestCommon.h │ ├── WaveTest.cpp │ ├── WebMTest.cpp │ ├── pch.cpp │ └── pch.h ├── build.bat ├── cmake │ ├── AddPlugin.cmake │ ├── FindFLAC.cmake │ ├── FindOgg.cmake │ ├── FindOpenEXR.cmake │ ├── FindOpus.cmake │ ├── FindVPX.cmake │ ├── FindVorbis.cmake │ ├── FindWEBM.cmake │ ├── FindYUV.cmake │ └── ISPC.cmake ├── external │ ├── 7z │ │ └── 7za.exe │ └── PluginAPI │ │ ├── IUnityEventQueue.h │ │ ├── IUnityGraphics.h │ │ ├── IUnityGraphicsD3D11.h │ │ ├── IUnityGraphicsD3D12.h │ │ ├── IUnityGraphicsD3D9.h │ │ ├── IUnityGraphicsMetal.h │ │ └── IUnityInterface.h ├── fccore.sln ├── fccore.vcxproj ├── fccore.vcxproj.filters ├── fccore │ ├── CMakeLists.txt │ ├── Encoder │ │ ├── Audio │ │ │ ├── fcFlacContext.cpp │ │ │ ├── fcFlacContext.h │ │ │ ├── fcOggContext.cpp │ │ │ ├── fcOggContext.h │ │ │ ├── fcWaveContext.cpp │ │ │ └── fcWaveContext.h │ │ ├── Image │ │ │ ├── fcExrContext.cpp │ │ │ ├── fcExrContext.h │ │ │ ├── fcGifContext.cpp │ │ │ ├── fcGifContext.h │ │ │ ├── fcPngContext.cpp │ │ │ ├── fcPngContext.h │ │ │ └── jo_gif.i │ │ ├── MP4 │ │ │ ├── fcAACEncoder.h │ │ │ ├── fcAACEncoderFAAC.cpp │ │ │ ├── fcAACEncoderIntel.cpp │ │ │ ├── fcH264Encoder.cpp │ │ │ ├── fcH264Encoder.h │ │ │ ├── fcH264EncoderAMD.cpp │ │ │ ├── fcH264EncoderIntel.cpp │ │ │ ├── fcH264EncoderNVIDIA.cpp │ │ │ ├── fcH264EncoderOpenH264.cpp │ │ │ ├── fcMP4Context.cpp │ │ │ ├── fcMP4Context.h │ │ │ ├── fcMP4Internal.h │ │ │ ├── fcMP4Writer.cpp │ │ │ ├── fcMP4Writer.h │ │ │ ├── fcMP4_Linux.cpp │ │ │ ├── fcMP4_Mac.cpp │ │ │ └── fcMP4_Windows.cpp │ │ └── WebM │ │ │ ├── fcOpusEncoder.cpp │ │ │ ├── fcVPXEncoder.cpp │ │ │ ├── fcVPXEncoder.h │ │ │ ├── fcVorbisEncoder.cpp │ │ │ ├── fcVorbisEncoder.h │ │ │ ├── fcWebMContext.cpp │ │ │ ├── fcWebMContext.h │ │ │ ├── fcWebMInternal.h │ │ │ ├── fcWebMWriter.cpp │ │ │ └── fcWebMWriter.h │ ├── Foundation │ │ ├── Buffer.cpp │ │ ├── Buffer.h │ │ ├── Compression.cpp │ │ ├── ConvertKernel.ispc │ │ ├── LazyInstance.h │ │ ├── Misc.cpp │ │ ├── Misc.h │ │ ├── Network.cpp │ │ ├── PixelFormat.cpp │ │ ├── PixelFormat.h │ │ ├── TaskGroup.cpp │ │ ├── TaskGroup.h │ │ ├── TaskQueue.cpp │ │ ├── TaskQueue.h │ │ ├── YUV.cpp │ │ ├── YUV.h │ │ └── fcFoundation.h │ ├── GraphicsDevice │ │ ├── fcGraphicsDevice.cpp │ │ ├── fcGraphicsDevice.h │ │ ├── fcGraphicsDeviceD3D11.cpp │ │ ├── fcGraphicsDeviceD3D9.cpp │ │ └── fcGraphicsDeviceOpenGL.cpp │ ├── fcInternal.cpp │ ├── fcInternal.h │ ├── fccore.cpp │ ├── fccore.h │ ├── pch.cpp │ └── pch.h ├── fccore_x86.def ├── setup.bat └── setup.vcxproj ├── README.md └── Screenshots ├── ExrLayers.png ├── ExrOffscreenRecorder.png ├── ExrRecorder.png ├── GifOffscreenRecorder.png ├── GifRecorder.png ├── MP4OffscreenRecorder.png ├── MP4Recorder.png ├── PngOffscreenRecorder.png ├── PngRecorder.png ├── exr_example1.png ├── gif_capturer.gif └── gif_example1.gif /.gitignore: -------------------------------------------------------------------------------- 1 | *.ipch 2 | *.sdf 3 | *.opendb 4 | *.db 5 | *.user 6 | *.log 7 | *.tlog 8 | 9 | *.exe 10 | *.dll 11 | *.bundle 12 | *.dylib 13 | *.so 14 | *.exr 15 | *.gif 16 | *.png 17 | *.mp4 18 | *.h264 19 | *.aac 20 | *.webm 21 | *.ogg 22 | *.flac 23 | *.wav 24 | 25 | .vs/ 26 | _out/ 27 | _tmp/ 28 | _build_*/ 29 | external/ 30 | Library/ 31 | Temp/ 32 | 33 | FrameCapturer/*.csproj 34 | FrameCapturer/*.sln 35 | FrameRecorder/ 36 | FrameRecorder.meta 37 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/FrameCapturerPackaging.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEditor; 3 | 4 | 5 | public class FrameCapturerPackaging 6 | { 7 | [MenuItem("Assets/Make FrameCapturer.unitypackage")] 8 | public static void MakePackage() 9 | { 10 | { 11 | string[] files = new string[] 12 | { 13 | "Assets/UTJ", 14 | "Assets/StreamingAssets/UTJ", 15 | "Assets/Unity", 16 | }; 17 | AssetDatabase.ExportPackage(files, "FrameCapturer.unitypackage", ExportPackageOptions.Recurse); 18 | } 19 | } 20 | 21 | } 22 | #endif // UNITY_EDITOR 23 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/FrameCapturerPackaging.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b938caae9048f034380165a310a29e8a 3 | timeCreated: 1433462956 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/FrameRecorderTest.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/FrameRecorderTest.unity -------------------------------------------------------------------------------- /FrameCapturer/Assets/FrameRecorderTest.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ea596845c657dc94fb331657c51b968d 3 | timeCreated: 1494216507 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/StreamingAssets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac4ffb2007a96be45870d7acd7b8f57e 3 | folderAsset: yes 4 | timeCreated: 1457806452 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/StreamingAssets/UTJ.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1851881336bf9a44388a0051a301628d 3 | folderAsset: yes 4 | timeCreated: 1457806452 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/StreamingAssets/UTJ/FrameCapturer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94a951d32d09b2044b947c7f85b41be9 3 | folderAsset: yes 4 | timeCreated: 1457806476 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/StreamingAssets/UTJ/FrameCapturer/License.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 999348212bf87d2498da7e6df0f0d7d0 3 | timeCreated: 1457815014 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f2033c6c2cf36045b59e4c2d695ab66 3 | folderAsset: yes 4 | timeCreated: 1433021095 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Animations.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2db0a453eb3a96247b7a249c416659db 3 | folderAsset: yes 4 | timeCreated: 1433110228 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Animations/Camera1.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/TestData/Animations/Camera1.anim -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Animations/Camera1.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d5aa323a9516af4fa6cfda5f78c4ee4 3 | timeCreated: 1433110506 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Animations/CameraRig.controller: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/TestData/Animations/CameraRig.controller -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Animations/CameraRig.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 042ca51ded705204296ab2c4a7b31123 3 | timeCreated: 1433110506 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07b9e92306d53234ab6a21c028001c08 3 | folderAsset: yes 4 | timeCreated: 1432973924 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/Raymarcher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c3efb58f5df06c41a36f96820663e83 3 | timeCreated: 1426231168 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/Raymarcher.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/TestData/Raymarching/Raymarcher.mat -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/Raymarcher.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9c214dfb3bf15840affa2fd2324bcde 3 | timeCreated: 1426931396 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/Raymarcher.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44055804a40ff9e4098900dfa3987b97 3 | timeCreated: 1426229747 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/TestStandard.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/TestData/Raymarching/TestStandard.mat -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/TestStandard.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e1fd07a64fd9b248a2fbda75febe73c 3 | timeCreated: 1426648713 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/distance_functions.cginc: -------------------------------------------------------------------------------- 1 | #ifndef distance_functions_h 2 | #define distance_functions_h 3 | 4 | #include "foundation.cginc" 5 | 6 | float kaleidoscopic_IFS(float3 z) 7 | { 8 | int FRACT_ITER = 20; 9 | float FRACT_SCALE = 1.8; 10 | float FRACT_OFFSET = 1.0; 11 | 12 | float c = 2.0; 13 | z.y = modc(z.y, c)-c/2.0; 14 | z = rotateZ(z, PI/2.0); 15 | float r; 16 | int n1 = 0; 17 | for (int n = 0; n < FRACT_ITER; n++) { 18 | float rotate = PI*0.5; 19 | z = rotateX(z, rotate); 20 | z = rotateY(z, rotate); 21 | z = rotateZ(z, rotate); 22 | 23 | z.xy = abs(z.xy); 24 | if (z.x+z.y<0.0) z.xy = -z.yx; // fold 1 25 | if (z.x+z.z<0.0) z.xz = -z.zx; // fold 2 26 | if (z.y+z.z<0.0) z.zy = -z.yz; // fold 3 27 | z = z*FRACT_SCALE - FRACT_OFFSET*(FRACT_SCALE-1.0); 28 | } 29 | return (length(z) ) * pow(FRACT_SCALE, -float(FRACT_ITER)); 30 | } 31 | 32 | 33 | float tglad_formula(float3 z0) 34 | { 35 | float sp = length(z0+float3(0.0, 2.0, 0.0))-_Time.y*1.5; 36 | z0 = modc(z0, 2.0); 37 | 38 | float mr=0.25, mxr=1.0; 39 | float4 scale=float4(-3.12,-3.12,-3.12,3.12), p0=float4(0.0,1.59,-1.0,0.0); 40 | float4 z = float4(z0,1.0); 41 | for (int n = 0; n < 3; n++) { 42 | z.xyz=clamp(z.xyz, -0.94, 0.94)*2.0-z.xyz; 43 | z*=scale/clamp(dot(z.xyz,z.xyz),mr,mxr); 44 | z+=p0; 45 | } 46 | float dS=(length(max(abs(z.xyz)-float3(1.2,49.0,1.4),0.0))-0.06)/z.w; 47 | dS = max(sp, dS); 48 | return dS; 49 | } 50 | 51 | 52 | // distance function from Hartverdrahtet 53 | // ( http://www.pouet.net/prod.php?which=59086 ) 54 | float hartverdrahtet(float3 f) 55 | { 56 | float3 cs=float3(.808,.808,1.167); 57 | float fs=1.; 58 | float3 fc=0; 59 | float fu=10.; 60 | float fd=.763; 61 | 62 | // scene selection 63 | { 64 | float time = _Time.y; 65 | int i = int(modc(time/2.0, 9.0)); 66 | if(i==0) cs.y=.58; 67 | if(i==1) cs.xy=.5; 68 | if(i==2) cs.xy=.5; 69 | if(i==3) fu=1.01,cs.x=.9; 70 | if(i==4) fu=1.01,cs.x=.9; 71 | if(i==6) cs=float3(.5,.5,1.04); 72 | if(i==5) fu=.9; 73 | if(i==7) fd=.7,fs=1.34,cs.xy=.5; 74 | if(i==8) fc.z=-.38; 75 | } 76 | 77 | //cs += sin(time)*0.2; 78 | 79 | float v=1.; 80 | for(int i=0; i<12; i++){ 81 | f=2.*clamp(f,-cs,cs)-f; 82 | float c=max(fs/dot(f,f),1.); 83 | f*=c; 84 | v*=c; 85 | f+=fc; 86 | } 87 | float z=length(f.xy)-fu; 88 | return fd*max(z,abs(length(f.xy)*f.z)/sqrt(dot(f,f)))/abs(v); 89 | } 90 | 91 | float pseudo_kleinian(float3 p) 92 | { 93 | float3 CSize = float3(0.92436,0.90756,0.92436); 94 | float Size = 1.0; 95 | float3 C = float3(0.0,0.0,0.0); 96 | float DEfactor=1.; 97 | float3 Offset = float3(0.0,0.0,0.0); 98 | float3 ap=p+1.; 99 | for(int i=0;i<10 ;i++){ 100 | ap=p; 101 | p=2.*clamp(p, -CSize, CSize)-p; 102 | float r2 = dot(p,p); 103 | float k = max(Size/r2,1.); 104 | p *= k; 105 | DEfactor *= k + 0.05; 106 | p += C; 107 | } 108 | float r = abs(0.5*abs(p.z-Offset.z)/DEfactor); 109 | return r; 110 | } 111 | 112 | float pseudo_knightyan(float3 p) 113 | { 114 | float3 CSize = float3(0.63248,0.78632,0.875); 115 | float DEfactor=1.; 116 | for(int i=0;i<6;i++){ 117 | p = 2.*clamp(p, -CSize, CSize)-p; 118 | float k = max(0.70968/dot(p,p),1.); 119 | p *= k; 120 | DEfactor *= k + 0.05; 121 | } 122 | float rxy=length(p.xy); 123 | return max(rxy-0.92784, abs(rxy*p.z) / length(p))/DEfactor; 124 | } 125 | 126 | #endif // distance_functions_h 127 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/distance_functions.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf7d029044c45114fa3d9e39af8e5f0d 3 | timeCreated: 1426486978 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/foundation.cginc: -------------------------------------------------------------------------------- 1 | #ifndef foundation_h 2 | #define foundation_h 3 | 4 | #include "UnityCG.cginc" 5 | 6 | #define PI 3.1415926535897932384626433832795 7 | 8 | float deg2rad(float deg) { return deg*PI/180.0; } 9 | float2 deg2rad(float2 deg) { return deg*PI/180.0; } 10 | float3 deg2rad(float3 deg) { return deg*PI/180.0; } 11 | float4 deg2rad(float4 deg) { return deg*PI/180.0; } 12 | 13 | float modc(float a, float b) { return a - b * floor(a/b); } 14 | float2 modc(float2 a, float2 b) { return a - b * floor(a/b); } 15 | float3 modc(float3 a, float3 b) { return a - b * floor(a/b); } 16 | float4 modc(float4 a, float4 b) { return a - b * floor(a/b); } 17 | 18 | float3 get_camera_position() { return _WorldSpaceCameraPos; } 19 | float3 get_camera_forward() { return -UNITY_MATRIX_V[2].xyz; } 20 | float3 get_camera_up() { return UNITY_MATRIX_V[1].xyz; } 21 | float3 get_camera_right() { return UNITY_MATRIX_V[0].xyz; } 22 | float get_camera_focal_length() { return abs(UNITY_MATRIX_P[1][1]); } 23 | 24 | float compute_depth(float4 clippos) 25 | { 26 | #if defined(SHADER_TARGET_GLSL) 27 | return ((clippos.z / clippos.w) + 1.0) * 0.5; 28 | #else 29 | return clippos.z / clippos.w; 30 | #endif 31 | } 32 | 33 | sampler2D g_depth_prev; 34 | sampler2D g_depth; 35 | sampler2D g_velocity; 36 | 37 | float cross_depth_sample(float2 t, sampler2D s, float o) 38 | { 39 | float2 p = (_ScreenParams.zw - 1.0)*o; 40 | float d1 = tex2D(s, t).x; 41 | float d2 = min( 42 | min(tex2D(s, t+float2( p.x, 0.0)).x, tex2D(s, t+float2(-p.x, 0.0))).x, 43 | min(tex2D(s, t+float2( 0.0, p.y)).x, tex2D(s, t+float2( 0.0,-p.y))).x ); 44 | return min(d1, d2); 45 | } 46 | 47 | float sample_prev_depth(float2 t) 48 | { 49 | return max(tex2D(g_depth_prev, t).x-0.001, _ProjectionParams.y); 50 | } 51 | 52 | float sample_upper_depth(float2 t) 53 | { 54 | return max(cross_depth_sample(t, g_depth, 2.0)*0.995, _ProjectionParams.y); 55 | } 56 | 57 | 58 | float3 rotateX(float3 p, float angle) 59 | { 60 | float c = cos(angle); 61 | float s = sin(angle); 62 | return float3(p.x, c*p.y+s*p.z, -s*p.y+c*p.z); 63 | } 64 | 65 | float3 rotateY(float3 p, float angle) 66 | { 67 | float c = cos(angle); 68 | float s = sin(angle); 69 | return float3(c*p.x-s*p.z, p.y, s*p.x+c*p.z); 70 | } 71 | 72 | float3 rotateZ(float3 p, float angle) 73 | { 74 | float c = cos(angle); 75 | float s = sin(angle); 76 | return float3(c*p.x+s*p.y, -s*p.x+c*p.y, p.z); 77 | } 78 | 79 | float4x4 translation_matrix(float3 t) 80 | { 81 | return float4x4( 82 | 1.0, 0.0, 0.0, t.x, 83 | 0.0, 1.0, 0.0, t.y, 84 | 0.0, 0.0, 1.0, t.z, 85 | 0.0, 0.0, 0.0, 1.0 ); 86 | } 87 | 88 | float3x3 axis_rotation_matrix33(float3 axis, float angle) 89 | { 90 | axis = normalize(axis); 91 | float s = sin(angle); 92 | float c = cos(angle); 93 | float oc = 1.0 - c; 94 | return float3x3( 95 | oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 96 | oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 97 | oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c ); 98 | } 99 | 100 | #endif // foundation_h 101 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Raymarching/foundation.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12298b74437b2174eb2dbe64e19e339d 3 | timeCreated: 1426614250 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Sounds.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 368c6eb83fc86364d8d3865b91f95a18 3 | folderAsset: yes 4 | timeCreated: 1455612668 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Sounds/demo.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/TestData/Sounds/demo.mp3 -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Sounds/demo.mp3.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2079eade2a0af314d80876aadd51b146 3 | timeCreated: 1455612676 4 | licenseType: Pro 5 | AudioImporter: 6 | serializedVersion: 6 7 | defaultSettings: 8 | loadType: 0 9 | sampleRateSetting: 0 10 | sampleRateOverride: 44100 11 | compressionFormat: 1 12 | quality: 1 13 | conversionMode: 0 14 | platformSettingOverrides: {} 15 | forceToMono: 0 16 | normalize: 1 17 | preloadAudioData: 1 18 | loadInBackground: 0 19 | 3D: 1 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Utilities.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df9c531dd89b66b4f9a9e58dd7efbe31 3 | folderAsset: yes 4 | timeCreated: 1432977187 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Utilities/CameraControl.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Threading; 5 | 6 | [ExecuteInEditMode] 7 | public class CameraControl : MonoBehaviour 8 | { 9 | public bool m_mouse_control = true; 10 | public bool m_rotate_by_time = false; 11 | public float m_rotate_speed = -10.0f; 12 | public Camera m_camera; 13 | public Transform m_look_target; 14 | 15 | public float m_follow_strength; 16 | public Vector3 m_target_offset; 17 | Vector3 m_look_pos; 18 | 19 | void Awake() 20 | { 21 | m_look_pos = m_look_target.position; 22 | } 23 | 24 | void Update() 25 | { 26 | if (m_camera == null || m_look_target == null) return; 27 | Transform cam_t = m_camera.GetComponent(); 28 | 29 | if (Input.GetKeyUp(KeyCode.R)) { m_rotate_by_time = !m_rotate_by_time; } 30 | 31 | Vector3 pos = cam_t.position - m_look_target.position; 32 | if (m_rotate_by_time) 33 | { 34 | pos = Quaternion.Euler(0.0f, Time.deltaTime * m_rotate_speed, 0) * pos; 35 | } 36 | 37 | if(m_mouse_control) 38 | { 39 | if (Input.GetMouseButton(0) || Input.GetMouseButton(1)) 40 | { 41 | float ry = Input.GetAxis("Mouse X") * 3.0f; 42 | float rxz = Input.GetAxis("Mouse Y") * 0.25f; 43 | pos = Quaternion.Euler(0.0f, ry, 0) * pos; 44 | pos.y += rxz; 45 | } 46 | { 47 | float wheel = Input.GetAxis("Mouse ScrollWheel"); 48 | pos += pos.normalized * wheel * 4.0f; 49 | } 50 | } 51 | cam_t.position = pos + m_look_target.position; 52 | 53 | if(m_mouse_control) 54 | { 55 | if (Input.GetMouseButton(2)) 56 | { 57 | float xz = Input.GetAxis("Mouse X") * -0.1f; 58 | float y = Input.GetAxis("Mouse Y") * -0.1f; 59 | var rel = m_camera.cameraToWorldMatrix * new Vector4(xz, y, 0.0f, 0.0f); 60 | cam_t.position = cam_t.position + (Vector3)rel; 61 | m_look_target.position = m_look_target.position + (Vector3)rel; 62 | } 63 | } 64 | 65 | m_look_pos += (m_look_target.position - m_look_pos) * m_follow_strength; 66 | cam_t.transform.LookAt(m_look_pos + m_target_offset); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Utilities/CameraControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cbebbe0f7a8ad7b47a7ad82aed9d20d8 3 | timeCreated: 1426421297 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Utilities/FrameRateCounter.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | [RequireComponent(typeof(GUIText))] 5 | public class FrameRateCounter : MonoBehaviour 6 | { 7 | public float m_update_interval = 0.5f; 8 | private float m_last_time; 9 | private float m_accum = 0.0f; // FPS accumulated over the interval 10 | private int m_frames = 0; // Frames drawn over the interval 11 | private float m_time_left; // Left time for current interval 12 | private float m_result; 13 | 14 | void Start() 15 | { 16 | m_time_left = m_update_interval; 17 | m_last_time = Time.realtimeSinceStartup; 18 | } 19 | 20 | void Update() 21 | { 22 | float now = Time.realtimeSinceStartup; 23 | float delta = now - m_last_time; 24 | m_last_time = now; 25 | m_time_left -= delta; 26 | m_accum += 1.0f / delta; 27 | ++m_frames; 28 | 29 | // Interval ended - update result 30 | if (m_time_left <= 0.0) 31 | { 32 | m_result = m_accum / m_frames; 33 | GetComponent().text = m_result.ToString("f2"); 34 | m_time_left = m_update_interval; 35 | m_accum = 0.0f; 36 | m_frames = 0; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Utilities/FrameRateCounter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df845f9544e8e00409ea0b3102335733 3 | timeCreated: 1428656934 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Utilities/FrameRateCounter.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/TestData/Utilities/FrameRateCounter.prefab -------------------------------------------------------------------------------- /FrameCapturer/Assets/TestData/Utilities/FrameRateCounter.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d354555475239704c8e75ba6c0f088bf 3 | timeCreated: 1428656997 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f2e937c06a3aa48459b5a7475e11570c 3 | folderAsset: yes 4 | timeCreated: 1453544223 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 522bab85d8eab374194107c6d00ba0e5 3 | folderAsset: yes 4 | timeCreated: 1432793486 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e8066324c8ba02488f823792218ad75 3 | folderAsset: yes 4 | timeCreated: 1493972568 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/AudioEncoderConfigDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace UTJ.FrameCapturer 5 | { 6 | [CustomPropertyDrawer(typeof(AudioEncoderConfigs))] 7 | class AudioEncoderConfigsDrawer : PropertyDrawer 8 | { 9 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 10 | { 11 | return 0.0f; 12 | } 13 | 14 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 15 | { 16 | var type = property.FindPropertyRelative("format"); 17 | EditorGUILayout.PropertyField(type); 18 | EditorGUI.indentLevel++; 19 | switch ((AudioEncoder.Type)type.intValue) 20 | { 21 | case AudioEncoder.Type.Wave: 22 | EditorGUILayout.PropertyField(property.FindPropertyRelative("waveEncoderSettings"), true); 23 | break; 24 | case AudioEncoder.Type.Ogg: 25 | EditorGUILayout.PropertyField(property.FindPropertyRelative("oggEncoderSettings"), true); 26 | break; 27 | case AudioEncoder.Type.Flac: 28 | EditorGUILayout.PropertyField(property.FindPropertyRelative("flacEncoderSettings"), true); 29 | break; 30 | } 31 | EditorGUI.indentLevel--; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/AudioEncoderConfigDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d37e99b22a0420240a5efe886afba75c 3 | timeCreated: 1494516670 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/AudioRecorderEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | [CustomEditor(typeof(AudioRecorder))] 8 | public class AudioRecorderEditor : RecorderBaseEditor 9 | { 10 | public override void OnInspectorGUI() 11 | { 12 | var so = serializedObject; 13 | 14 | CommonConfig(); 15 | EditorGUILayout.Space(); 16 | FramerateControl(); 17 | EditorGUILayout.Space(); 18 | RecordingControl(); 19 | 20 | so.ApplyModifiedProperties(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/AudioRecorderEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e85d227bfdde1c4ebb0db593dc10c1c 3 | timeCreated: 1494516962 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/GBufferRecorderEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | [CustomEditor(typeof(GBufferRecorder))] 8 | public class ImageSequenceRecorderEditor : RecorderBaseEditor 9 | { 10 | public override void OnInspectorGUI() 11 | { 12 | //DrawDefaultInspector(); 13 | 14 | var recorder = target as GBufferRecorder; 15 | var so = serializedObject; 16 | 17 | CommonConfig(); 18 | 19 | EditorGUILayout.Space(); 20 | EditorGUILayout.LabelField("Capture Components"); 21 | EditorGUI.indentLevel++; 22 | { 23 | EditorGUI.BeginChangeCheck(); 24 | var fbc = recorder.fbComponents; 25 | 26 | fbc.frameBuffer = EditorGUILayout.Toggle("Frame Buffer", fbc.frameBuffer); 27 | if(fbc.frameBuffer) 28 | { 29 | EditorGUI.indentLevel++; 30 | fbc.fbColor = EditorGUILayout.Toggle("Color", fbc.fbColor); 31 | fbc.fbAlpha = EditorGUILayout.Toggle("Alpha", fbc.fbAlpha); 32 | EditorGUI.indentLevel--; 33 | } 34 | 35 | fbc.GBuffer = EditorGUILayout.Toggle("GBuffer", fbc.GBuffer); 36 | if (fbc.GBuffer) 37 | { 38 | EditorGUI.indentLevel++; 39 | fbc.gbAlbedo = EditorGUILayout.Toggle("Albedo", fbc.gbAlbedo); 40 | fbc.gbOcclusion = EditorGUILayout.Toggle("Occlusion", fbc.gbOcclusion); 41 | fbc.gbSpecular = EditorGUILayout.Toggle("Specular", fbc.gbSpecular); 42 | fbc.gbSmoothness= EditorGUILayout.Toggle("Smoothness", fbc.gbSmoothness); 43 | fbc.gbNormal = EditorGUILayout.Toggle("Normal", fbc.gbNormal); 44 | fbc.gbEmission = EditorGUILayout.Toggle("Emission", fbc.gbEmission); 45 | fbc.gbDepth = EditorGUILayout.Toggle("Depth", fbc.gbDepth); 46 | fbc.gbVelocity = EditorGUILayout.Toggle("Velocity", fbc.gbVelocity); 47 | EditorGUI.indentLevel--; 48 | } 49 | if (EditorGUI.EndChangeCheck()) 50 | { 51 | recorder.fbComponents = fbc; 52 | EditorUtility.SetDirty(recorder); 53 | } 54 | } 55 | EditorGUI.indentLevel--; 56 | 57 | EditorGUILayout.Space(); 58 | 59 | ResolutionControl(); 60 | FramerateControl(); 61 | 62 | EditorGUILayout.Space(); 63 | 64 | RecordingControl(); 65 | 66 | so.ApplyModifiedProperties(); 67 | } 68 | 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/GBufferRecorderEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b00edfdbd1f8de4b8a40e518dbde401 3 | timeCreated: 1494007084 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7cbd21b9490d0e4d9f828a4595c1f00 3 | folderAsset: yes 4 | timeCreated: 1494004663 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc/BoolDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace UTJ.FrameCapturer 5 | { 6 | [CustomPropertyDrawer(typeof(Bool))] 7 | class BoolDrawer : PropertyDrawer 8 | { 9 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 10 | { 11 | EditorGUI.BeginProperty(position, label, property); 12 | position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); 13 | 14 | var indent = EditorGUI.indentLevel; 15 | EditorGUI.indentLevel = 0; 16 | 17 | var p = property.FindPropertyRelative("v"); 18 | bool value = p.intValue != 0; 19 | 20 | EditorGUI.BeginChangeCheck(); 21 | value = EditorGUI.Toggle(position, value); 22 | if (EditorGUI.EndChangeCheck()) 23 | { 24 | p.intValue = value ? 1 : 0; 25 | } 26 | 27 | EditorGUI.indentLevel = indent; 28 | EditorGUI.EndProperty(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc/BoolDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7234308adeab3d419817de7e29c50f1 3 | timeCreated: 1494004664 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc/DataPathDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace UTJ.FrameCapturer 5 | { 6 | [CustomPropertyDrawer(typeof(DataPath))] 7 | class DataPathDrawer : PropertyDrawer 8 | { 9 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 10 | { 11 | bool ro = property.FindPropertyRelative("m_readOnly").boolValue; 12 | if(ro) { EditorGUI.BeginDisabledGroup(true); } 13 | 14 | EditorGUI.BeginProperty(position, label, property); 15 | position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); 16 | 17 | var indent = EditorGUI.indentLevel; 18 | EditorGUI.indentLevel = 0; 19 | 20 | float buttonWidth = 22; 21 | float rootWidth = 70; 22 | float leafWidth = position.width - rootWidth - 5 - buttonWidth; 23 | var rootRect = new Rect(position.x, position.y, rootWidth, position.height); 24 | var leafRect = new Rect(position.x + rootWidth + 5, position.y, leafWidth, position.height); 25 | var buttonRect = new Rect(position.x + rootWidth + 5 + leafWidth, position.y, buttonWidth, position.height); 26 | 27 | var pRoot = property.FindPropertyRelative("m_root"); 28 | var pLeaf = property.FindPropertyRelative("m_leaf"); 29 | EditorGUI.PropertyField(rootRect, pRoot, GUIContent.none); 30 | EditorGUI.PropertyField(leafRect, pLeaf, GUIContent.none); 31 | if (GUI.Button(buttonRect, "...")) 32 | { 33 | var tmp = new DataPath((DataPath.Root)pRoot.intValue, pLeaf.stringValue); 34 | var path = EditorUtility.OpenFolderPanel("Select Directory", tmp.GetFullPath(), ""); 35 | if (path.Length > 0) 36 | { 37 | var newPath = new DataPath(path); 38 | pRoot.intValue = (int)newPath.root; 39 | pLeaf.stringValue = newPath.leaf; 40 | } 41 | } 42 | 43 | EditorGUI.indentLevel = indent; 44 | EditorGUI.EndProperty(); 45 | 46 | if (ro) { EditorGUI.EndDisabledGroup(); } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/Misc/DataPathDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2c8844522598244c853bbfcb74cf8ac 3 | timeCreated: 1494004664 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/MovieEncoderConfigDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace UTJ.FrameCapturer 5 | { 6 | [CustomPropertyDrawer(typeof(MovieEncoderConfigs))] 7 | class MovieEncoderConfigsDrawer : PropertyDrawer 8 | { 9 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 10 | { 11 | return 0.0f; 12 | } 13 | 14 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 15 | { 16 | var type = property.FindPropertyRelative("format"); 17 | EditorGUILayout.PropertyField(type); 18 | EditorGUI.indentLevel++; 19 | switch ((MovieEncoder.Type)type.intValue) 20 | { 21 | case MovieEncoder.Type.Png: 22 | EditorGUILayout.PropertyField(property.FindPropertyRelative("pngEncoderSettings"), true); 23 | break; 24 | case MovieEncoder.Type.Exr: 25 | EditorGUILayout.PropertyField(property.FindPropertyRelative("exrEncoderSettings"), true); 26 | break; 27 | case MovieEncoder.Type.Gif: 28 | EditorGUILayout.PropertyField(property.FindPropertyRelative("gifEncoderSettings"), true); 29 | break; 30 | case MovieEncoder.Type.WebM: 31 | EditorGUILayout.PropertyField(property.FindPropertyRelative("webmEncoderSettings"), true); 32 | break; 33 | case MovieEncoder.Type.MP4: 34 | EditorGUILayout.PropertyField(property.FindPropertyRelative("mp4EncoderSettings"), true); 35 | break; 36 | } 37 | EditorGUI.indentLevel--; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/MovieEncoderConfigDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95451e4e68362fb4095b5bba3a47096a 3 | timeCreated: 1494313411 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/MovieRecorderEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | [CustomEditor(typeof(MovieRecorder))] 8 | public class MovieRecorderEditor : RecorderBaseEditor 9 | { 10 | public virtual void VideoConfig() 11 | { 12 | var recorder = target as MovieRecorder; 13 | var so = serializedObject; 14 | 15 | EditorGUILayout.PropertyField(so.FindProperty("m_captureTarget")); 16 | if(recorder.captureTarget == MovieRecorder.CaptureTarget.RenderTexture) 17 | { 18 | EditorGUI.indentLevel++; 19 | EditorGUILayout.PropertyField(so.FindProperty("m_targetRT")); 20 | EditorGUI.indentLevel--; 21 | } 22 | 23 | ResolutionControl(); 24 | EditorGUILayout.PropertyField(so.FindProperty("m_captureEveryNthFrame")); 25 | } 26 | 27 | 28 | public virtual void AudioConfig() 29 | { 30 | } 31 | 32 | public override void OnInspectorGUI() 33 | { 34 | //DrawDefaultInspector(); 35 | 36 | var recorder = target as MovieRecorder; 37 | var so = serializedObject; 38 | 39 | CommonConfig(); 40 | 41 | EditorGUILayout.Space(); 42 | 43 | if (recorder.supportVideo && !recorder.supportAudio) 44 | { 45 | VideoConfig(); 46 | } 47 | else if (!recorder.supportVideo && recorder.supportAudio) 48 | { 49 | AudioConfig(); 50 | } 51 | else if (recorder.supportVideo && recorder.supportAudio) 52 | { 53 | EditorGUILayout.PropertyField(so.FindProperty("m_captureVideo")); 54 | if (recorder.captureVideo) 55 | { 56 | EditorGUI.indentLevel++; 57 | VideoConfig(); 58 | EditorGUI.indentLevel--; 59 | } 60 | EditorGUILayout.Space(); 61 | 62 | EditorGUILayout.PropertyField(so.FindProperty("m_captureAudio")); 63 | if (recorder.captureAudio) 64 | { 65 | EditorGUI.indentLevel++; 66 | AudioConfig(); 67 | EditorGUI.indentLevel--; 68 | } 69 | } 70 | 71 | EditorGUILayout.Space(); 72 | FramerateControl(); 73 | EditorGUILayout.Space(); 74 | RecordingControl(); 75 | 76 | so.ApplyModifiedProperties(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/MovieRecorderEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 16bccb8f58e67a348b23389b312ec2d6 3 | timeCreated: 1493972568 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Editor/RecorderBaseEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cac941334b980ff489d8d28bfde34140 3 | timeCreated: 1494741859 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 178d677034729554ba412d8026f03471 3 | folderAsset: yes 4 | timeCreated: 1432793503 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6a99610875e99f4a86c25c0d98826fb 3 | folderAsset: yes 4 | timeCreated: 1433034131 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86/fccore.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af2eb4260adfc8648ace36d39d74522f 3 | timeCreated: 1493911880 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 2 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | data: 13 | first: 14 | '': Any 15 | second: 16 | enabled: 0 17 | settings: 18 | Exclude Editor: 0 19 | Exclude Linux: 0 20 | Exclude Linux64: 0 21 | Exclude LinuxUniversal: 0 22 | Exclude OSXIntel: 0 23 | Exclude OSXIntel64: 0 24 | Exclude OSXUniversal: 0 25 | Exclude Win: 0 26 | Exclude Win64: 1 27 | data: 28 | first: 29 | '': Editor 30 | second: 31 | enabled: 0 32 | settings: 33 | CPU: x86 34 | OS: Windows 35 | data: 36 | first: 37 | Any: 38 | second: 39 | enabled: 1 40 | settings: {} 41 | data: 42 | first: 43 | Editor: Editor 44 | second: 45 | enabled: 1 46 | settings: 47 | CPU: x86 48 | DefaultValueInitialized: true 49 | data: 50 | first: 51 | Facebook: Win 52 | second: 53 | enabled: 1 54 | settings: 55 | CPU: AnyCPU 56 | data: 57 | first: 58 | Facebook: Win64 59 | second: 60 | enabled: 0 61 | settings: 62 | CPU: None 63 | data: 64 | first: 65 | Standalone: Linux 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: x86 70 | data: 71 | first: 72 | Standalone: Linux64 73 | second: 74 | enabled: 1 75 | settings: 76 | CPU: None 77 | data: 78 | first: 79 | Standalone: LinuxUniversal 80 | second: 81 | enabled: 1 82 | settings: 83 | CPU: AnyCPU 84 | data: 85 | first: 86 | Standalone: OSXIntel 87 | second: 88 | enabled: 1 89 | settings: 90 | CPU: AnyCPU 91 | data: 92 | first: 93 | Standalone: OSXIntel64 94 | second: 95 | enabled: 1 96 | settings: 97 | CPU: None 98 | data: 99 | first: 100 | Standalone: OSXUniversal 101 | second: 102 | enabled: 1 103 | settings: 104 | CPU: AnyCPU 105 | data: 106 | first: 107 | Standalone: Win 108 | second: 109 | enabled: 1 110 | settings: 111 | CPU: AnyCPU 112 | data: 113 | first: 114 | Standalone: Win64 115 | second: 116 | enabled: 0 117 | settings: 118 | CPU: None 119 | userData: 120 | assetBundleName: 121 | assetBundleVariant: 122 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb423a2251dfbf04488bb95a0f1ec0e1 3 | folderAsset: yes 4 | timeCreated: 1432793511 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64/fccore.bundle.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 095a7aaa840de2c40b28e8f46c6527bd 3 | folderAsset: yes 4 | timeCreated: 1494431117 5 | licenseType: Pro 6 | PluginImporter: 7 | serializedVersion: 2 8 | iconMap: {} 9 | executionOrder: {} 10 | isPreloaded: 0 11 | isOverridable: 0 12 | platformData: 13 | data: 14 | first: 15 | '': Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Editor: 0 20 | Exclude Linux: 0 21 | Exclude Linux64: 0 22 | Exclude LinuxUniversal: 0 23 | Exclude OSXIntel: 1 24 | Exclude OSXIntel64: 0 25 | Exclude OSXUniversal: 0 26 | Exclude Win: 0 27 | Exclude Win64: 0 28 | data: 29 | first: 30 | Any: 31 | second: 32 | enabled: 1 33 | settings: {} 34 | data: 35 | first: 36 | Editor: Editor 37 | second: 38 | enabled: 1 39 | settings: 40 | CPU: x86_64 41 | DefaultValueInitialized: true 42 | OS: OSX 43 | data: 44 | first: 45 | Facebook: Win 46 | second: 47 | enabled: 0 48 | settings: 49 | CPU: None 50 | data: 51 | first: 52 | Facebook: Win64 53 | second: 54 | enabled: 1 55 | settings: 56 | CPU: AnyCPU 57 | data: 58 | first: 59 | Standalone: Linux 60 | second: 61 | enabled: 1 62 | settings: 63 | CPU: None 64 | data: 65 | first: 66 | Standalone: Linux64 67 | second: 68 | enabled: 1 69 | settings: 70 | CPU: x86_64 71 | data: 72 | first: 73 | Standalone: LinuxUniversal 74 | second: 75 | enabled: 1 76 | settings: 77 | CPU: AnyCPU 78 | data: 79 | first: 80 | Standalone: OSXIntel 81 | second: 82 | enabled: 0 83 | settings: 84 | CPU: None 85 | data: 86 | first: 87 | Standalone: OSXIntel64 88 | second: 89 | enabled: 1 90 | settings: 91 | CPU: AnyCPU 92 | data: 93 | first: 94 | Standalone: OSXUniversal 95 | second: 96 | enabled: 1 97 | settings: 98 | CPU: x86_64 99 | data: 100 | first: 101 | Standalone: Win 102 | second: 103 | enabled: 1 104 | settings: 105 | CPU: None 106 | data: 107 | first: 108 | Standalone: Win64 109 | second: 110 | enabled: 1 111 | settings: 112 | CPU: AnyCPU 113 | userData: 114 | assetBundleName: 115 | assetBundleVariant: 116 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64/fccore.bundle/Contents.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96396973072080b44b74b8b56e8ca90f 3 | folderAsset: yes 4 | timeCreated: 1494431117 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64/fccore.bundle/Contents/Info.plist.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae3adaf31cbcac144bd5778be1e565ed 3 | timeCreated: 1494431117 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64/fccore.bundle/Contents/MacOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b5d1e24071d5d1e46ace7e1af1f324bb 3 | folderAsset: yes 4 | timeCreated: 1494431117 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64/fccore.bundle/Contents/MacOS/fccore.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ebc87403d133ba04da787b7ea5967b1f 3 | timeCreated: 1494431117 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64/fccore.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dfc932324fbf314586b61e5e846c01c 3 | timeCreated: 1494024139 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 2 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | data: 13 | first: 14 | '': Any 15 | second: 16 | enabled: 0 17 | settings: 18 | Exclude Editor: 0 19 | Exclude Linux: 0 20 | Exclude Linux64: 0 21 | Exclude LinuxUniversal: 0 22 | Exclude OSXIntel: 0 23 | Exclude OSXIntel64: 0 24 | Exclude OSXUniversal: 0 25 | Exclude Win: 1 26 | Exclude Win64: 0 27 | data: 28 | first: 29 | '': Editor 30 | second: 31 | enabled: 0 32 | settings: 33 | CPU: x86_64 34 | OS: Windows 35 | data: 36 | first: 37 | Any: 38 | second: 39 | enabled: 1 40 | settings: {} 41 | data: 42 | first: 43 | Editor: Editor 44 | second: 45 | enabled: 1 46 | settings: 47 | CPU: x86_64 48 | DefaultValueInitialized: true 49 | data: 50 | first: 51 | Facebook: Win 52 | second: 53 | enabled: 0 54 | settings: 55 | CPU: None 56 | data: 57 | first: 58 | Facebook: Win64 59 | second: 60 | enabled: 1 61 | settings: 62 | CPU: AnyCPU 63 | data: 64 | first: 65 | Standalone: Linux 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: None 70 | data: 71 | first: 72 | Standalone: Linux64 73 | second: 74 | enabled: 1 75 | settings: 76 | CPU: x86_64 77 | data: 78 | first: 79 | Standalone: LinuxUniversal 80 | second: 81 | enabled: 1 82 | settings: 83 | CPU: AnyCPU 84 | data: 85 | first: 86 | Standalone: OSXIntel 87 | second: 88 | enabled: 1 89 | settings: 90 | CPU: None 91 | data: 92 | first: 93 | Standalone: OSXIntel64 94 | second: 95 | enabled: 1 96 | settings: 97 | CPU: AnyCPU 98 | data: 99 | first: 100 | Standalone: OSXUniversal 101 | second: 102 | enabled: 1 103 | settings: 104 | CPU: AnyCPU 105 | data: 106 | first: 107 | Standalone: Win 108 | second: 109 | enabled: 0 110 | settings: 111 | CPU: None 112 | data: 113 | first: 114 | Standalone: Win64 115 | second: 116 | enabled: 1 117 | settings: 118 | CPU: AnyCPU 119 | userData: 120 | assetBundleName: 121 | assetBundleVariant: 122 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64/libfccore.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 726e163b375ffbd4caea3b963d13652e 3 | timeCreated: 1494430105 4 | licenseType: Pro 5 | PluginImporter: 6 | serializedVersion: 2 7 | iconMap: {} 8 | executionOrder: {} 9 | isPreloaded: 0 10 | isOverridable: 0 11 | platformData: 12 | data: 13 | first: 14 | '': Any 15 | second: 16 | enabled: 0 17 | settings: 18 | Exclude Editor: 0 19 | Exclude Linux: 1 20 | Exclude Linux64: 0 21 | Exclude LinuxUniversal: 0 22 | Exclude OSXIntel: 1 23 | Exclude OSXIntel64: 1 24 | Exclude OSXUniversal: 1 25 | Exclude Win: 0 26 | Exclude Win64: 0 27 | data: 28 | first: 29 | Any: 30 | second: 31 | enabled: 1 32 | settings: {} 33 | data: 34 | first: 35 | Editor: Editor 36 | second: 37 | enabled: 1 38 | settings: 39 | CPU: x86_64 40 | DefaultValueInitialized: true 41 | OS: Linux 42 | data: 43 | first: 44 | Facebook: Win 45 | second: 46 | enabled: 0 47 | settings: 48 | CPU: None 49 | data: 50 | first: 51 | Facebook: Win64 52 | second: 53 | enabled: 1 54 | settings: 55 | CPU: AnyCPU 56 | data: 57 | first: 58 | Standalone: Linux 59 | second: 60 | enabled: 0 61 | settings: 62 | CPU: None 63 | data: 64 | first: 65 | Standalone: Linux64 66 | second: 67 | enabled: 1 68 | settings: 69 | CPU: x86_64 70 | data: 71 | first: 72 | Standalone: LinuxUniversal 73 | second: 74 | enabled: 1 75 | settings: 76 | CPU: x86_64 77 | data: 78 | first: 79 | Standalone: OSXIntel 80 | second: 81 | enabled: 0 82 | settings: 83 | CPU: None 84 | data: 85 | first: 86 | Standalone: OSXIntel64 87 | second: 88 | enabled: 0 89 | settings: 90 | CPU: None 91 | data: 92 | first: 93 | Standalone: OSXUniversal 94 | second: 95 | enabled: 0 96 | settings: 97 | CPU: None 98 | data: 99 | first: 100 | Standalone: Win 101 | second: 102 | enabled: 1 103 | settings: 104 | CPU: None 105 | data: 106 | first: 107 | Standalone: Win64 108 | second: 109 | enabled: 1 110 | settings: 111 | CPU: AnyCPU 112 | userData: 113 | assetBundleName: 114 | assetBundleVariant: 115 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2eb1eb6bf0605b8469d2d383642f1fe4 3 | folderAsset: yes 4 | timeCreated: 1432793494 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/AudioRecorder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | 6 | 7 | namespace UTJ.FrameCapturer 8 | { 9 | [AddComponentMenu("UTJ/FrameCapturer/Audio Recorder")] 10 | [RequireComponent(typeof(AudioListener))] 11 | [ExecuteInEditMode] 12 | public class AudioRecorder : RecorderBase 13 | { 14 | #region fields 15 | [SerializeField] AudioEncoderConfigs m_encoderConfigs = new AudioEncoderConfigs(); 16 | AudioEncoder m_encoder; 17 | #endregion 18 | 19 | 20 | public override bool BeginRecording() 21 | { 22 | if (m_recording) { return false; } 23 | 24 | m_outputDir.CreateDirectory(); 25 | 26 | // initialize encoder 27 | { 28 | string outPath = m_outputDir.GetFullPath() + "/" + DateTime.Now.ToString("yyyyMMdd_HHmmss"); 29 | 30 | m_encoderConfigs.Setup(); 31 | m_encoder = AudioEncoder.Create(m_encoderConfigs, outPath); 32 | if (m_encoder == null || !m_encoder.IsValid()) 33 | { 34 | EndRecording(); 35 | return false; 36 | } 37 | } 38 | 39 | base.BeginRecording(); 40 | Debug.Log("AudioMRecorder: BeginRecording()"); 41 | return true; 42 | } 43 | 44 | public override void EndRecording() 45 | { 46 | if (m_encoder != null) 47 | { 48 | m_encoder.Release(); 49 | m_encoder = null; 50 | } 51 | 52 | if (m_recording) 53 | { 54 | Debug.Log("AudioMRecorder: EndRecording()"); 55 | } 56 | base.EndRecording(); 57 | 58 | } 59 | 60 | 61 | #region impl 62 | void LateUpdate() 63 | { 64 | ++m_frame; 65 | } 66 | 67 | void OnAudioFilterRead(float[] samples, int channels) 68 | { 69 | if (m_recording && m_encoder != null) 70 | { 71 | m_encoder.AddAudioSamples(samples); 72 | m_recordedSamples += samples.Length; 73 | } 74 | } 75 | #endregion 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/AudioRecorder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 264fb370ec254fe4591ad390d173ceb2 3 | timeCreated: 1494460973 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fde401d160f133842addfb7db5ae4c97 3 | folderAsset: yes 4 | timeCreated: 1494318897 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/AudioEncoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | 6 | 7 | namespace UTJ.FrameCapturer 8 | { 9 | [Serializable] 10 | public class AudioEncoderConfigs 11 | { 12 | public AudioEncoder.Type format = AudioEncoder.Type.Flac; 13 | public fcAPI.fcWaveConfig waveEncoderSettings = fcAPI.fcWaveConfig.default_value; 14 | public fcAPI.fcOggConfig oggEncoderSettings = fcAPI.fcOggConfig.default_value; 15 | public fcAPI.fcFlacConfig flacEncoderSettings = fcAPI.fcFlacConfig.default_value; 16 | 17 | public void Setup() 18 | { 19 | } 20 | } 21 | 22 | public abstract class AudioEncoder : EncoderBase 23 | { 24 | public enum Type 25 | { 26 | Wave, 27 | Ogg, 28 | Flac, 29 | } 30 | static public Type[] GetAvailableEncoderTypes() 31 | { 32 | var ret = new List(); 33 | if (fcAPI.fcWaveIsSupported()) { ret.Add(Type.Wave); } 34 | if (fcAPI.fcOggIsSupported()) { ret.Add(Type.Ogg); } 35 | if (fcAPI.fcFlacIsSupported()) { ret.Add(Type.Flac); } 36 | return ret.ToArray(); 37 | } 38 | 39 | 40 | public abstract Type type { get; } 41 | 42 | // config: config struct (fcGifConfig, fcWebMConfig, etc) 43 | public abstract void Initialize(object config, string outPath); 44 | public abstract void AddAudioSamples(float[] samples); 45 | 46 | 47 | public static AudioEncoder Create(Type t) 48 | { 49 | switch (t) 50 | { 51 | case Type.Wave: return new WaveEncoder(); 52 | case Type.Ogg: return new OggEncoder(); 53 | case Type.Flac: return new FlacEncoder(); 54 | } 55 | return null; 56 | } 57 | 58 | public static AudioEncoder Create(AudioEncoderConfigs c, string path) 59 | { 60 | var ret = Create(c.format); 61 | switch (c.format) 62 | { 63 | case Type.Wave: ret.Initialize(c.waveEncoderSettings, path); break; 64 | case Type.Ogg: ret.Initialize(c.oggEncoderSettings, path); break; 65 | case Type.Flac: ret.Initialize(c.flacEncoderSettings, path); break; 66 | } 67 | return ret; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/AudioEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a237ca86d54fa1f4088547fad559cd49 3 | timeCreated: 1494460406 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/EncoderBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEngine.Rendering; 4 | 5 | 6 | namespace UTJ.FrameCapturer 7 | { 8 | public abstract class EncoderBase 9 | { 10 | public EncoderBase() 11 | { 12 | AppDomain.CurrentDomain.DomainUnload += WaitAsyncDelete; 13 | } 14 | public static void WaitAsyncDelete(object sender, EventArgs e) 15 | { 16 | fcAPI.fcWaitAsyncDelete(); 17 | } 18 | 19 | public abstract void Release(); 20 | public abstract bool IsValid(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/EncoderBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5078fb266c916184bb5cd9e635b82f9d 3 | timeCreated: 1494630775 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/ExrEncoder.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.Rendering; 4 | 5 | 6 | namespace UTJ.FrameCapturer 7 | { 8 | public class ExrEncoder : MovieEncoder 9 | { 10 | static readonly string[] s_channelNames = { "R", "G", "B", "A" }; 11 | fcAPI.fcExrContext m_ctx; 12 | fcAPI.fcExrConfig m_config; 13 | string m_outPath; 14 | int m_frame; 15 | 16 | public override void Release() { m_ctx.Release(); } 17 | public override bool IsValid() { return m_ctx; } 18 | public override Type type { get { return Type.Exr; } } 19 | 20 | public override void Initialize(object config, string outPath) 21 | { 22 | if (!fcAPI.fcExrIsSupported()) 23 | { 24 | Debug.LogError("Exr encoder is not available on this platform."); 25 | return; 26 | } 27 | 28 | m_config = (fcAPI.fcExrConfig)config; 29 | m_ctx = fcAPI.fcExrCreateContext(ref m_config); 30 | m_outPath = outPath; 31 | m_frame = 0; 32 | } 33 | 34 | public override void AddVideoFrame(byte[] frame, fcAPI.fcPixelFormat format, double timestamp = -1.0) 35 | { 36 | if (m_ctx) 37 | { 38 | string path = m_outPath + "_" + m_frame.ToString("0000") + ".exr"; 39 | int channels = System.Math.Min(m_config.channels, (int)format & 7); 40 | 41 | fcAPI.fcExrBeginImage(m_ctx, path, m_config.width, m_config.height); 42 | for (int i = 0; i < channels; ++i) 43 | { 44 | fcAPI.fcExrAddLayerPixels(m_ctx, frame, format, i, s_channelNames[i]); 45 | } 46 | fcAPI.fcExrEndImage(m_ctx); 47 | } 48 | ++m_frame; 49 | } 50 | 51 | public override void AddAudioSamples(float[] samples) 52 | { 53 | // not supported 54 | } 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/ExrEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2edf1ed5e1f1c8544b925c302853bbb8 3 | timeCreated: 1494000131 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/FlacEncoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | public class FlacEncoder : AudioEncoder 8 | { 9 | fcAPI.fcFlacContext m_ctx; 10 | fcAPI.fcFlacConfig m_config; 11 | 12 | public override void Release() { m_ctx.Release(); } 13 | public override bool IsValid() { return m_ctx; } 14 | public override Type type { get { return Type.Flac; } } 15 | 16 | public override void Initialize(object config, string outPath) 17 | { 18 | if (!fcAPI.fcFlacIsSupported()) 19 | { 20 | Debug.LogError("Flac encoder is not available on this platform."); 21 | return; 22 | } 23 | 24 | m_config = (fcAPI.fcFlacConfig)config; 25 | m_config.sampleRate = AudioSettings.outputSampleRate; 26 | m_config.numChannels = fcAPI.fcGetNumAudioChannels(); 27 | m_ctx = fcAPI.fcFlacCreateContext(ref m_config); 28 | 29 | var path = outPath + ".flac"; 30 | var stream = fcAPI.fcCreateFileStream(path); 31 | fcAPI.fcFlacAddOutputStream(m_ctx, stream); 32 | stream.Release(); 33 | } 34 | 35 | public override void AddAudioSamples(float[] samples) 36 | { 37 | if (m_ctx) 38 | { 39 | fcAPI.fcFlacAddAudioSamples(m_ctx, samples, samples.Length); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/FlacEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: de9a4cfb1e5acbf44a178668df9a378d 3 | timeCreated: 1494460081 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/GifEncoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | public class GifEncoder : MovieEncoder 8 | { 9 | fcAPI.fcGifContext m_ctx; 10 | fcAPI.fcGifConfig m_config; 11 | 12 | public override void Release() { m_ctx.Release(); } 13 | public override bool IsValid() { return m_ctx; } 14 | public override Type type { get { return Type.Gif; } } 15 | 16 | public override void Initialize(object config, string outPath) 17 | { 18 | if (!fcAPI.fcGifIsSupported()) 19 | { 20 | Debug.LogError("Gif encoder is not available on this platform."); 21 | return; 22 | } 23 | 24 | m_config = (fcAPI.fcGifConfig)config; 25 | m_config.numColors = Mathf.Clamp(m_config.numColors, 1, 256); 26 | m_ctx = fcAPI.fcGifCreateContext(ref m_config); 27 | 28 | var path = outPath + ".gif"; 29 | var stream = fcAPI.fcCreateFileStream(path); 30 | fcAPI.fcGifAddOutputStream(m_ctx, stream); 31 | stream.Release(); 32 | } 33 | 34 | public override void AddVideoFrame(byte[] frame, fcAPI.fcPixelFormat format, double timestamp) 35 | { 36 | if (m_ctx) 37 | { 38 | fcAPI.fcGifAddFramePixels(m_ctx, frame, format, timestamp); 39 | } 40 | } 41 | 42 | public override void AddAudioSamples(float[] samples) 43 | { 44 | // not supported 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/GifEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e328bea6ad6257848a01305be866b33b 3 | timeCreated: 1493996447 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/MP4Encoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | public class MP4Encoder : MovieEncoder 8 | { 9 | fcAPI.fcMP4Context m_ctx; 10 | fcAPI.fcMP4Config m_config; 11 | 12 | public override void Release() { m_ctx.Release(); } 13 | public override bool IsValid() { return m_ctx; } 14 | public override Type type { get { return Type.MP4; } } 15 | 16 | public override void Initialize(object config, string outPath) 17 | { 18 | if (!fcAPI.fcMP4OSIsSupported()) 19 | { 20 | Debug.LogError("MP4 encoder is not available on this platform."); 21 | return; 22 | } 23 | 24 | m_config = (fcAPI.fcMP4Config)config; 25 | m_config.audioSampleRate = AudioSettings.outputSampleRate; 26 | m_config.audioNumChannels = fcAPI.fcGetNumAudioChannels(); 27 | 28 | var path = outPath + ".mp4"; 29 | m_ctx = fcAPI.fcMP4OSCreateContext(ref m_config, path); 30 | } 31 | 32 | public override void AddVideoFrame(byte[] frame, fcAPI.fcPixelFormat format, double timestamp) 33 | { 34 | if (m_ctx && m_config.video) 35 | { 36 | fcAPI.fcMP4AddVideoFramePixels(m_ctx, frame, format, timestamp); 37 | } 38 | } 39 | 40 | public override void AddAudioSamples(float[] samples) 41 | { 42 | if (m_ctx && m_config.audio) 43 | { 44 | fcAPI.fcMP4AddAudioSamples(m_ctx, samples, samples.Length); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/MP4Encoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15136ad38d3c16f4d91a6c802884de03 3 | timeCreated: 1493996447 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/MovieEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05a483774a00261429ff072ba4a63bea 3 | timeCreated: 1493995555 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/OggEncoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | public class OggEncoder : AudioEncoder 8 | { 9 | fcAPI.fcOggContext m_ctx; 10 | fcAPI.fcOggConfig m_config; 11 | 12 | public override void Release() { m_ctx.Release(); } 13 | public override bool IsValid() { return m_ctx; } 14 | public override Type type { get { return Type.Ogg; } } 15 | 16 | public override void Initialize(object config, string outPath) 17 | { 18 | if (!fcAPI.fcOggIsSupported()) 19 | { 20 | Debug.LogError("Ogg encoder is not available on this platform."); 21 | return; 22 | } 23 | 24 | m_config = (fcAPI.fcOggConfig)config; 25 | m_config.sampleRate = AudioSettings.outputSampleRate; 26 | m_config.numChannels = fcAPI.fcGetNumAudioChannels(); 27 | m_ctx = fcAPI.fcOggCreateContext(ref m_config); 28 | 29 | var path = outPath + ".ogg"; 30 | var stream = fcAPI.fcCreateFileStream(path); 31 | fcAPI.fcOggAddOutputStream(m_ctx, stream); 32 | stream.Release(); 33 | } 34 | 35 | public override void AddAudioSamples(float[] samples) 36 | { 37 | if(m_ctx) 38 | { 39 | fcAPI.fcOggAddAudioSamples(m_ctx, samples, samples.Length); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/OggEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d73bca5c7709074dab1e33c534c5015 3 | timeCreated: 1494516452 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/PngEncoder.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | 4 | namespace UTJ.FrameCapturer 5 | { 6 | public class PngEncoder : MovieEncoder 7 | { 8 | fcAPI.fcPngContext m_ctx; 9 | fcAPI.fcPngConfig m_config; 10 | string m_outPath; 11 | int m_frame; 12 | 13 | 14 | public override void Release() { m_ctx.Release(); } 15 | public override bool IsValid() { return m_ctx; } 16 | public override Type type { get { return Type.Png; } } 17 | 18 | public override void Initialize(object config, string outPath) 19 | { 20 | if (!fcAPI.fcPngIsSupported()) 21 | { 22 | Debug.LogError("Png encoder is not available on this platform."); 23 | return; 24 | } 25 | 26 | m_config = (fcAPI.fcPngConfig)config; 27 | m_ctx = fcAPI.fcPngCreateContext(ref m_config); 28 | m_outPath = outPath; 29 | m_frame = 0; 30 | } 31 | 32 | public override void AddVideoFrame(byte[] frame, fcAPI.fcPixelFormat format, double timestamp = -1.0) 33 | { 34 | if (m_ctx) 35 | { 36 | string path = m_outPath + "_" + m_frame.ToString("0000") + ".png"; 37 | int channels = System.Math.Min(m_config.channels, (int)format & 7); 38 | fcAPI.fcPngExportPixels(m_ctx, path, frame, m_config.width, m_config.height, format, channels); 39 | } 40 | ++m_frame; 41 | } 42 | 43 | public override void AddAudioSamples(float[] samples) 44 | { 45 | // not supported 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/PngEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb579d3ab681ded4bbcd41bac0530cb4 3 | timeCreated: 1494000131 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/WaveEncoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | public class WaveEncoder : AudioEncoder 8 | { 9 | fcAPI.fcWaveContext m_ctx; 10 | fcAPI.fcWaveConfig m_config; 11 | 12 | public override void Release() { m_ctx.Release(); } 13 | public override bool IsValid() { return m_ctx; } 14 | public override Type type { get { return Type.Wave; } } 15 | 16 | public override void Initialize(object config, string outPath) 17 | { 18 | if (!fcAPI.fcWaveIsSupported()) 19 | { 20 | Debug.LogError("Wave encoder is not available on this platform."); 21 | return; 22 | } 23 | 24 | m_config = (fcAPI.fcWaveConfig)config; 25 | m_config.sampleRate = AudioSettings.outputSampleRate; 26 | m_config.numChannels = fcAPI.fcGetNumAudioChannels(); 27 | m_ctx = fcAPI.fcWaveCreateContext(ref m_config); 28 | 29 | var path = outPath + ".wave"; 30 | var stream = fcAPI.fcCreateFileStream(path); 31 | fcAPI.fcWaveAddOutputStream(m_ctx, stream); 32 | stream.Release(); 33 | } 34 | 35 | public override void AddAudioSamples(float[] samples) 36 | { 37 | if(m_ctx) 38 | { 39 | fcAPI.fcWaveAddAudioSamples(m_ctx, samples, samples.Length); 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/WaveEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 294b105c376faa845995d961f1e3a434 3 | timeCreated: 1494460081 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/WebMEncoder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | 5 | namespace UTJ.FrameCapturer 6 | { 7 | public class WebMEncoder : MovieEncoder 8 | { 9 | fcAPI.fcWebMContext m_ctx; 10 | fcAPI.fcWebMConfig m_config; 11 | 12 | public override void Release() { m_ctx.Release(); } 13 | public override bool IsValid() { return m_ctx; } 14 | public override Type type { get { return Type.WebM; } } 15 | 16 | public override void Initialize(object config, string outPath) 17 | { 18 | if (!fcAPI.fcWebMIsSupported()) 19 | { 20 | Debug.LogError("WebM encoder is not available on this platform."); 21 | return; 22 | } 23 | 24 | m_config = (fcAPI.fcWebMConfig)config; 25 | if (m_config.audio && m_config.audioEncoder == fcAPI.fcWebMAudioEncoder.Opus) 26 | { 27 | var sampleRate = AudioSettings.outputSampleRate; 28 | if (sampleRate != 8000 && sampleRate != 12000 && sampleRate != 16000 && sampleRate != 24000 && sampleRate != 48000) 29 | { 30 | Debug.LogError("Current output sample rate is " + sampleRate + ". It must be 8000, 12000, 16000, 24000 or 48000 to use Opus audio encoder. Fallback to Vorbis."); 31 | m_config.audioEncoder = fcAPI.fcWebMAudioEncoder.Vorbis; 32 | } 33 | } 34 | 35 | m_config.audioSampleRate = AudioSettings.outputSampleRate; 36 | m_config.audioNumChannels = fcAPI.fcGetNumAudioChannels(); 37 | m_ctx = fcAPI.fcWebMCreateContext(ref m_config); 38 | 39 | var path = outPath + ".webm"; 40 | var stream = fcAPI.fcCreateFileStream(path); 41 | fcAPI.fcWebMAddOutputStream(m_ctx, stream); 42 | stream.Release(); 43 | } 44 | 45 | public override void AddVideoFrame(byte[] frame, fcAPI.fcPixelFormat format, double timestamp) 46 | { 47 | if (m_ctx && m_config.video) 48 | { 49 | fcAPI.fcWebMAddVideoFramePixels(m_ctx, frame, format, timestamp); 50 | } 51 | } 52 | 53 | public override void AddAudioSamples(float[] samples) 54 | { 55 | if (m_ctx && m_config.audio) 56 | { 57 | fcAPI.fcWebMAddAudioSamples(m_ctx, samples, samples.Length); 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/WebMEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: feb89bd50fd2c9b4589670dc229526c7 3 | timeCreated: 1493996447 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Encoder/fcAPI.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6913dd8876ab8149ac67f69aba208ac 3 | timeCreated: 1432919907 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/GBufferRecorder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 300557aa730d7984a8b4b12f91bfa3b2 3 | timeCreated: 1493993867 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Misc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 324c02e09f53928429e39bbbd971fa1c 3 | folderAsset: yes 4 | timeCreated: 1457073395 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Misc/Bool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UTJ.FrameCapturer 5 | { 6 | // bool is marshal as int (4 byte) by default and you need ugly [MarshalAs(UnmanagedType.U1)] to pass to (or receive from) C++ code. 7 | // this struct emulates bool and marshal as byte (1 byte). this makes things bit easier in some cases. 8 | [Serializable] 9 | public struct Bool 10 | { 11 | [SerializeField] byte v; 12 | public static implicit operator bool(Bool v) { return v.v != 0; } 13 | public static implicit operator Bool(bool v) { Bool r; r.v = v ? (byte)1 : (byte)0; return r; } 14 | 15 | public static Bool True { get { Bool r; r.v = (byte)1; return r; } } 16 | } 17 | } -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Misc/Bool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e74a0ade798956d49a6bbb833422663e 3 | timeCreated: 1457112037 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/Misc/DataPath.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fd1bcdf4e762654da9323b7b37cfecb 3 | timeCreated: 1457112037 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/MovieRecorder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 199311a1781af854fb1334c3c195468a 3 | timeCreated: 1455634659 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Scripts/RecorderBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29ac315c95aad34439a7dc4a107c3c35 3 | timeCreated: 1494734319 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e43556cd2e1f10e48ac6cc20c04e94a3 3 | folderAsset: yes 4 | timeCreated: 1432924708 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturer/Shaders/CopyFrameBuffer.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2283fb92223c7914c9096670e29202c8 3 | timeCreated: 1432965900 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9cb17e751bf5b54da0a3eace1893871 3 | folderAsset: yes 4 | timeCreated: 1433128581 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7dfa2763feea86d459f7431320ad48ee 3 | folderAsset: yes 4 | timeCreated: 1432797266 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Camera.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Camera.anim -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Camera.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 509e2a1c8a971324888c9056689fc789 3 | timeCreated: 1493887012 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 7400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/CameraRig.controller: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/CameraRig.controller -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/CameraRig.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc7f32bc4e68b484fbd5820aab2507b4 3 | timeCreated: 1493887012 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 9100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Sphere.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Sphere.anim -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Sphere.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 464cd1a53e42cdf4e8dc0add91d50017 3 | timeCreated: 1494168161 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 7400000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Sphere.controller: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Sphere.controller -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Animation/Sphere.controller.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b40a27a2d217d7840a9e9684186614e7 3 | timeCreated: 1494168161 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 9100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6dda3a27b1afee42addd9e3d4f21f1b 3 | folderAsset: yes 4 | timeCreated: 1494161269 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test1.mat -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a9eb127c080da64495766f509cba702 3 | timeCreated: 1494163862 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test2.mat -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test2.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7df773c1edb90744ca90e357edaee87e 3 | timeCreated: 1494161278 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test3.mat -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test3.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3229d91ca743404aa3c2b213a1e89ba 3 | timeCreated: 1494164206 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test4.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test4.mat -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Materials/Test4.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 07e266ac1cc2cba4f8e6456564bc25f3 3 | timeCreated: 1499928190 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 2100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 031c03053336c85448a6c276b1c3ded2 3 | folderAsset: yes 4 | timeCreated: 1494174781 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Prefabs/CameraRig.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Prefabs/CameraRig.prefab -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Prefabs/CameraRig.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a90437c91e3d4154cb2db98d9296b91f 3 | timeCreated: 1494174821 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Prefabs/Root.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Prefabs/Root.prefab -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Prefabs/Root.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19415a94a1b344a4bbf88249c1e0e17c 3 | timeCreated: 1494174787 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | mainObjectFileID: 100100000 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Test.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Test.unity -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24809c0f78c89b64eab4427929f07f52 3 | timeCreated: 1493887130 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/TestOffscreen.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/TestOffscreen.unity -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/TestOffscreen.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcbe4ff2bef2e5242b4466080d31749d 3 | timeCreated: 1457557306 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 989c74e63d19ead41ad8bad1871b6366 3 | folderAsset: yes 4 | timeCreated: 1433453590 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Textures/RenderTarget.renderTexture: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/Assets/UTJ/FrameCapturerExample/Textures/RenderTarget.renderTexture -------------------------------------------------------------------------------- /FrameCapturer/Assets/UTJ/FrameCapturerExample/Textures/RenderTarget.renderTexture.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9cff1cb8a7cff64f93e5143faccd53c 3 | timeCreated: 1457085462 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/NavMeshProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/NavMeshProjectSettings.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2017.1.0f3 2 | -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /FrameCapturer/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/FrameCapturer/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Unity Technologies Japan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Plugin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | project(fccore) 3 | 4 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) 5 | include(ISPC) 6 | include(AddPlugin) 7 | 8 | find_package(OpenEXR QUIET) 9 | find_package(ZLIB QUIET) 10 | find_package(PNG QUIET) 11 | find_package(YUV QUIET) 12 | find_package(WEBM QUIET) 13 | find_package(VPX QUIET) 14 | find_package(OGG QUIET) 15 | find_package(VORBIS QUIET) 16 | find_package(OPUS QUIET) 17 | find_package(FLAC QUIET) 18 | 19 | option(FC_ENABLE_PNG "Enable Png sequence exporter." ON) 20 | option(FC_ENABLE_EXR "Enable Exr sequence exporter." ON) 21 | option(FC_ENABLE_GIF "Enable Gif exporter." ON) 22 | option(FC_ENABLE_WEBM "Enable WebM exporter." ON) 23 | if(FC_ENABLE_WEBM) 24 | option(FC_ENABLE_VPX "Enable VPX encoder." ON) 25 | option(FC_ENABLE_VORBIS "Enable vorbis encoder." ON) 26 | option(FC_ENABLE_OPUS "Enable opus encoder." ON) 27 | endif() 28 | option(FC_ENABLE_MP4 "Enable MP4 exporter." OFF) 29 | if(FC_ENABLE_MP4) 30 | option(FC_ENABLE_OPENH264 "Enable OpenH264 encoder." OFF) 31 | option(FC_ENABLE_FAAC "Enable FAAC encoder." OFF) 32 | endif() 33 | option(FC_ENABLE_WAVE "Enable Wave exporter." ON) 34 | option(FC_ENABLE_FLAC "Enable Flac exporter." ON) 35 | 36 | option(FC_ENABLE_DEBUG "Enable debug functionalities." ON) 37 | option(FC_ENABLE_TEST "Build test." ON) 38 | 39 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 40 | include_directories(${CMAKE_SOURCE_DIR}) 41 | 42 | add_subdirectory(fccore) 43 | add_subdirectory(Test) 44 | -------------------------------------------------------------------------------- /Plugin/NatvisFile.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ size={m_size} }} 5 | 6 | m_size 7 | m_capacity 8 | 9 | m_size 10 | m_data 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Plugin/Test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(FC_ENABLE_TEST) 2 | set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") 3 | 4 | file(GLOB TEST_SOURCES *.cpp *.h) 5 | add_executable(Test ${TEST_SOURCES}) 6 | add_dependencies(Test fccore) 7 | target_link_libraries(Test fccore pthread) 8 | install(TARGETS Test DESTINATION .) 9 | endif() 10 | -------------------------------------------------------------------------------- /Plugin/Test/ConvertTest.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | 4 | const int Width = 320; 5 | const int Height = 240; 6 | 7 | 8 | template 9 | void ConvertTestImpl(fcIPngContext *ctx, RawVector& src) 10 | { 11 | char filename[128]; 12 | sprintf(filename, "%s_to_%s.png", GetPixelFormat::getName(), GetPixelFormat::getName()); 13 | 14 | RawVector dst; 15 | dst.resize(Width * Height); 16 | auto data = fcConvertPixelFormat(&dst[0], GetPixelFormat::value, &src[0], GetPixelFormat::value, src.size()); 17 | fcPngExportPixels(ctx, filename, data, Width, Height, GetPixelFormat::value); 18 | } 19 | 20 | void ConvertTest() 21 | { 22 | printf("ConvertTest begin\n"); 23 | 24 | fcPngConfig conf; 25 | fcIPngContext *ctx = fcPngCreateContext(&conf); 26 | 27 | #define TestCases(SrcT)\ 28 | {\ 29 | RawVector video_frame(Width * Height);\ 30 | CreateVideoData(&video_frame[0], Width, Height, 0);\ 31 | ConvertTestImpl(ctx, video_frame);\ 32 | ConvertTestImpl(ctx, video_frame);\ 33 | ConvertTestImpl(ctx, video_frame);\ 34 | ConvertTestImpl(ctx, video_frame);\ 35 | ConvertTestImpl(ctx, video_frame);\ 36 | ConvertTestImpl(ctx, video_frame);\ 37 | ConvertTestImpl(ctx, video_frame);\ 38 | ConvertTestImpl(ctx, video_frame);\ 39 | ConvertTestImpl(ctx, video_frame);\ 40 | ConvertTestImpl(ctx, video_frame);\ 41 | ConvertTestImpl(ctx, video_frame);\ 42 | ConvertTestImpl(ctx, video_frame);\ 43 | } 44 | 45 | TestCases(RGBAu8); 46 | TestCases(RGBu8); 47 | TestCases(RGu8); 48 | TestCases(Ru8); 49 | TestCases(RGBAf16); 50 | TestCases(RGBf16); 51 | TestCases(RGf16); 52 | TestCases(Rf16); 53 | TestCases(RGBAf32); 54 | TestCases(RGBf32); 55 | TestCases(RGf32); 56 | TestCases(Rf32); 57 | 58 | fcReleaseContext(ctx); 59 | 60 | printf("ConvertTest end\n"); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Plugin/Test/ExrTest.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | 4 | template 5 | void ExrTestImpl(fcIExrContext *ctx, const char *filename) 6 | { 7 | const int Width = 320; 8 | const int Height = 240; 9 | int channels = GetPixelFormat::value & fcPixelFormat_ChannelMask; 10 | const char *channel_names[] = { "R", "G", "B", "A" }; 11 | 12 | RawVector video_frame(Width * Height); 13 | CreateVideoData(&video_frame[0], Width, Height, 0); 14 | fcExrBeginImage(ctx, filename, Width, Height); 15 | for (int i = 0; i < channels; ++i) { 16 | fcExrAddLayerPixels(ctx, &video_frame[0], GetPixelFormat::value, i, channel_names[i]); 17 | } 18 | fcExrEndImage(ctx); 19 | } 20 | 21 | void ExrTest() 22 | { 23 | if (!fcExrIsSupported()) { 24 | printf("ExrTest: exr is not supported\n"); 25 | return; 26 | } 27 | 28 | printf("ExrTest begin\n"); 29 | 30 | fcIExrContext *ctx = fcExrCreateContext(); 31 | ExrTestImpl(ctx, "RGBAu8.exr"); 32 | ExrTestImpl(ctx, "RGBAf16.exr"); 33 | ExrTestImpl(ctx, "RGBAf32.exr"); 34 | fcReleaseContext(ctx); 35 | 36 | printf("ExrTest end\n"); 37 | } 38 | -------------------------------------------------------------------------------- /Plugin/Test/FlacTest.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | 4 | 5 | void FlacTest(int bits) 6 | { 7 | if (!fcFlacIsSupported()) { 8 | printf("FlacTest: flac is not supported\n"); 9 | return; 10 | } 11 | 12 | const int SamplingRate = 48000; 13 | const int DurationInSeconds = 10; 14 | 15 | char filename[32]; 16 | sprintf(filename, "test%dbits.flac", bits); 17 | 18 | fcFlacConfig conf; 19 | conf.sample_rate = SamplingRate; 20 | conf.num_channels = 1; 21 | conf.bits_per_sample = bits; 22 | fcStream *fstream = fcCreateFileStream(filename); 23 | fcIFlacContext *ctx = fcFlacCreateContext(&conf); 24 | fcFlacAddOutputStream(ctx, fstream); 25 | 26 | 27 | // add audio frames 28 | { 29 | RawVector audio_sample(SamplingRate); 30 | fcTime t = 0; 31 | while (t < (double)DurationInSeconds) { 32 | CreateAudioData(audio_sample.data(), (int)audio_sample.size(), t, 1.0f); 33 | fcFlacAddAudioSamples(ctx, audio_sample.data(), (int)audio_sample.size()); 34 | t += 1.0; 35 | } 36 | } 37 | 38 | fcReleaseContext(ctx); 39 | fcReleaseStream(fstream); 40 | } 41 | 42 | void FlacTest() 43 | { 44 | FlacTest(8); 45 | FlacTest(16); 46 | FlacTest(24); 47 | } 48 | -------------------------------------------------------------------------------- /Plugin/Test/GifTest.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | 4 | template 5 | void GifTestImpl(const char *filename) 6 | { 7 | const int Width = 320; 8 | const int Height = 240; 9 | const int frame_count = 30; 10 | 11 | fcGifConfig conf; 12 | conf.width = Width; 13 | conf.height = Height; 14 | fcStream *fstream = fcCreateFileStream(filename); 15 | fcIGifContext *ctx = fcGifCreateContext(&conf); 16 | fcGifAddOutputStream(ctx, fstream); 17 | 18 | fcTime t = 0; 19 | RawVector video_frame(Width * Height); 20 | for (int i = 0; i < frame_count; ++i) { 21 | CreateVideoData(&video_frame[0], Width, Height, i); 22 | fcGifAddFramePixels(ctx, &video_frame[0], GetPixelFormat::value, t); 23 | t += 1.0 / 30.0; 24 | } 25 | 26 | fcReleaseContext(ctx); 27 | fcReleaseStream(fstream); 28 | } 29 | 30 | void GifTest() 31 | { 32 | if (!fcGifIsSupported()) { 33 | printf("GifTest: gif is not supported\n"); 34 | return; 35 | } 36 | 37 | printf("GifTest begin\n"); 38 | 39 | std::vector> tasks; 40 | tasks.push_back(std::async(std::launch::async, []() { GifTestImpl("RGBu8.gif"); })); 41 | tasks.push_back(std::async(std::launch::async, []() { GifTestImpl("RGBf16.gif"); })); 42 | tasks.push_back(std::async(std::launch::async, []() { GifTestImpl("RGBf32.gif"); })); 43 | tasks.push_back(std::async(std::launch::async, []() { GifTestImpl("RGBAu8.gif"); })); 44 | tasks.push_back(std::async(std::launch::async, []() { GifTestImpl("RGBAf16.gif"); })); 45 | tasks.push_back(std::async(std::launch::async, []() { GifTestImpl("RGBAf32.gif"); })); 46 | 47 | for (auto& task : tasks) { task.get(); } 48 | 49 | printf("GifTest end\n"); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /Plugin/Test/GraphicsDevice.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #ifdef _WIN32 3 | #include 4 | #pragma comment(lib, "d3d11.lib") 5 | 6 | #include "../fccore/fccore.h" 7 | 8 | 9 | bool InitializeD3D11() 10 | { 11 | D3D_FEATURE_LEVEL feature_levels[] = { 12 | D3D_FEATURE_LEVEL_11_1, 13 | D3D_FEATURE_LEVEL_11_0, 14 | }; 15 | D3D_FEATURE_LEVEL valid_feature_level; 16 | 17 | IDXGIAdapter *adapter = nullptr; 18 | ID3D11Device *dev = nullptr; 19 | ID3D11DeviceContext *ctx = nullptr; 20 | HRESULT hr = D3D11CreateDevice( 21 | adapter, 22 | D3D_DRIVER_TYPE_HARDWARE, 23 | nullptr, 24 | 0, 25 | feature_levels, 26 | _countof(feature_levels), 27 | D3D11_SDK_VERSION, 28 | &dev, 29 | &valid_feature_level, 30 | &ctx); 31 | 32 | if (dev) { 33 | fcGfxInitializeD3D11(dev); 34 | return true; 35 | } 36 | else { 37 | return false; 38 | } 39 | } 40 | 41 | #else // _WIN32 42 | 43 | bool InitializeD3D11() { return false; } 44 | 45 | #endif // _WIN32 46 | -------------------------------------------------------------------------------- /Plugin/Test/OggTest.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | 4 | void OggTest() 5 | { 6 | if (!fcOggIsSupported()) { 7 | printf("OggTest: ogg is not supported\n"); 8 | return; 9 | } 10 | 11 | const int SamplingRate = 48000; 12 | const int DurationInSeconds = 10; 13 | 14 | char filename[32]; 15 | sprintf(filename, "test.ogg"); 16 | 17 | fcOggConfig conf; 18 | conf.sample_rate = SamplingRate; 19 | conf.num_channels = 1; 20 | fcStream *fstream = fcCreateFileStream(filename); 21 | fcIOggContext *ctx = fcOggCreateContext(&conf); 22 | fcOggAddOutputStream(ctx, fstream); 23 | 24 | 25 | // add audio frames 26 | { 27 | RawVector audio_sample(SamplingRate); 28 | fcTime t = 0; 29 | while (t < (double)DurationInSeconds) { 30 | CreateAudioData(audio_sample.data(), (int)audio_sample.size(), t, 1.0f); 31 | fcOggAddAudioSamples(ctx, audio_sample.data(), (int)audio_sample.size()); 32 | t += 1.0; 33 | } 34 | } 35 | 36 | fcReleaseContext(ctx); 37 | fcReleaseStream(fstream); 38 | } 39 | -------------------------------------------------------------------------------- /Plugin/Test/PngTest.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | 4 | template 5 | void PngTestImpl(fcIPngContext *ctx, const char *filename, bool flipY=false) 6 | { 7 | const int Width = 320; 8 | const int Height = 240; 9 | 10 | RawVector video_frame(Width * Height); 11 | CreateVideoData(&video_frame[0], Width, Height, 0); 12 | fcPngExportPixels(ctx, filename, &video_frame[0], Width, Height, GetPixelFormat::value, flipY); 13 | } 14 | 15 | void PngTest() 16 | { 17 | if (!fcPngIsSupported()) { 18 | printf("PngTest: png is not supported\n"); 19 | return; 20 | } 21 | 22 | printf("PngTest begin\n"); 23 | 24 | fcPngConfig conf; 25 | fcIPngContext *ctx = fcPngCreateContext(&conf); 26 | 27 | PngTestImpl(ctx, "RGBu8.png"); 28 | PngTestImpl(ctx, "RGBf16.png"); 29 | PngTestImpl(ctx, "RGBf32.png"); 30 | PngTestImpl(ctx, "RGBAu8.png"); 31 | PngTestImpl(ctx, "RGBAf16.png"); 32 | PngTestImpl(ctx, "RGBAf32.png"); 33 | PngTestImpl(ctx, "RGBAf32_Flip.png", true); 34 | 35 | fcReleaseContext(ctx); 36 | 37 | printf("PngTest end\n"); 38 | } 39 | -------------------------------------------------------------------------------- /Plugin/Test/Test.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | 4 | void PngTest(); 5 | void ExrTest(); 6 | void GifTest(); 7 | void MP4Test(); 8 | void WebMTest(); 9 | void WaveTest(); 10 | void OggTest(); 11 | void FlacTest(); 12 | void ConvertTest(); 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | bool png = false; 17 | bool exr = false; 18 | bool gif = false; 19 | bool mp4 = false; 20 | bool webm = false; 21 | bool wave = false; 22 | bool ogg = false; 23 | bool flac = false; 24 | bool convert = false; 25 | 26 | if (argc <= 1) { 27 | png = exr = gif = mp4 = webm = convert = true; 28 | //faac = true; 29 | } 30 | else { 31 | for (int i = 1; i < argc; ++i) { 32 | if (strstr(argv[i], "png")) { png = true; } 33 | else if (strstr(argv[i], "exr")) { exr = true; } 34 | else if (strstr(argv[i], "gif")) { gif = true; } 35 | else if (strstr(argv[i], "mp4")) { mp4 = true; } 36 | else if (strstr(argv[i], "webm")) { webm = true; } 37 | else if (strstr(argv[i], "wave")) { wave = true; } 38 | else if (strstr(argv[i], "ogg")) { ogg = true; } 39 | else if (strstr(argv[i], "flac")) { flac = true; } 40 | else if (strstr(argv[i], "convert")) { convert = true; } 41 | } 42 | } 43 | 44 | InitializeD3D11(); 45 | if (png) PngTest(); 46 | if (exr) ExrTest(); 47 | if (gif) GifTest(); 48 | if (mp4) MP4Test(); 49 | if (webm) WebMTest(); 50 | if (wave) WaveTest(); 51 | if (ogg) OggTest(); 52 | if (flac) FlacTest(); 53 | if (convert) ConvertTest(); 54 | 55 | fcWaitAsyncDelete(); 56 | } 57 | -------------------------------------------------------------------------------- /Plugin/Test/TestCommon.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | #ifdef _WIN32 4 | #pragma comment(lib, "Half.lib") 5 | #endif 6 | 7 | 8 | template T White(); 9 | template T Black(); 10 | 11 | template<> Ru8 White() { return Ru8(255); } 12 | template<> Rf16 White() { return Rf16(1.0f); } 13 | template<> Rf32 White() { return Rf32(1.0f); } 14 | template<> RGu8 White() { return RGu8(255, 255); } 15 | template<> RGf16 White() { return RGf16(1.0f, 1.0f); } 16 | template<> RGf32 White() { return RGf32(1.0f, 1.0f); } 17 | template<> RGBu8 White() { return RGBu8(255, 255, 255); } 18 | template<> RGBf16 White() { return RGBf16(1.0f, 1.0f, 1.0f); } 19 | template<> RGBf32 White() { return RGBf32(1.0f, 1.0f, 1.0f); } 20 | template<> RGBAu8 White() { return RGBAu8(255, 255, 255, 255); } 21 | template<> RGBAf16 White() { return RGBAf16(1.0f, 1.0f, 1.0f, 1.0f); } 22 | template<> RGBAf32 White() { return RGBAf32(1.0f, 1.0f, 1.0f, 1.0f); } 23 | 24 | template<> Ru8 Black() { return Ru8(0); } 25 | template<> Rf16 Black() { return Rf16(0.0f); } 26 | template<> Rf32 Black() { return Rf32(0.0f); } 27 | template<> RGu8 Black() { return RGu8(0, 0); } 28 | template<> RGf16 Black() { return RGf16(0.0f, 0.0f); } 29 | template<> RGf32 Black() { return RGf32(0.0f, 0.0f); } 30 | template<> RGBu8 Black() { return RGBu8(0, 0, 0); } 31 | template<> RGBf16 Black() { return RGBf16(0.0f, 0.0f, 0.0f); } 32 | template<> RGBf32 Black() { return RGBf32(0.0f, 0.0f, 0.0f); } 33 | template<> RGBAu8 Black() { return RGBAu8(0, 0, 0, 255); } 34 | template<> RGBAf16 Black() { return RGBAf16(0.0f, 0.0f, 0.0f, 1.0f); } 35 | template<> RGBAf32 Black() { return RGBAf32(0.0f, 0.0f, 0.0f, 1.0f); } 36 | 37 | 38 | template 39 | void CreateVideoData(T *pixels, int width, int height, int frame) 40 | { 41 | const int block_size = 32; 42 | for (int iy = 0; iy < height; iy++) { 43 | for (int ix = 0; ix < width; ix++) { 44 | int ip = iy * width + ix; 45 | int yb = iy / block_size; 46 | int xb = (ix + iy + frame) / block_size; 47 | 48 | if ((xb) % 2 == 0) { 49 | pixels[ip] = White(); 50 | } 51 | else { 52 | pixels[ip] = Black(); 53 | } 54 | } 55 | } 56 | } 57 | 58 | template void CreateVideoData< Ru8 >(Ru8 *pixels, int width, int height, int frame); 59 | template void CreateVideoData< Rf16>(Rf16 *pixels, int width, int height, int frame); 60 | template void CreateVideoData< Rf32>(Rf32 *pixels, int width, int height, int frame); 61 | template void CreateVideoData< RGu8 >(RGu8 *pixels, int width, int height, int frame); 62 | template void CreateVideoData< RGf16>(RGf16 *pixels, int width, int height, int frame); 63 | template void CreateVideoData< RGf32>(RGf32 *pixels, int width, int height, int frame); 64 | template void CreateVideoData< RGBu8 >(RGBu8 *pixels, int width, int height, int frame); 65 | template void CreateVideoData< RGBf16>(RGBf16 *pixels, int width, int height, int frame); 66 | template void CreateVideoData< RGBf32>(RGBf32 *pixels, int width, int height, int frame); 67 | template void CreateVideoData(RGBAu8 *pixels, int width, int height, int frame); 68 | template void CreateVideoData(RGBAf16 *pixels, int width, int height, int frame); 69 | template void CreateVideoData(RGBAf32 *pixels, int width, int height, int frame); 70 | 71 | 72 | void CreateAudioData(float *samples, int num_samples, double t, float scale) 73 | { 74 | for (int i = 0; i < num_samples; ++i) { 75 | samples[i] = std::sin((float(i + ((double)num_samples * t)) * 5.5f) * (3.14159f / 180.0f)) * scale; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Plugin/Test/TestCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef _MSC_VER 4 | #pragma warning(disable: 4190) 5 | #define _CRT_SECURE_NO_WARNINGS 6 | #endif 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "../fccore/fccore.h" 15 | #include "../fccore/Foundation/fcFoundation.h" 16 | 17 | 18 | using u8 = uint8_t; 19 | using i16 = int16_t; 20 | using f16 = half; 21 | using f32 = float; 22 | 23 | template struct TR { 24 | T r; 25 | 26 | TR() : r() {} 27 | TR(T _r) : r(_r) {} 28 | }; 29 | template struct TRG { 30 | T r, g; 31 | 32 | TRG() : r(), g() {} 33 | TRG(T _r, T _g) : r(_r), g(_g) {} 34 | }; 35 | template struct TRGB { 36 | T r, g, b; 37 | 38 | TRGB() : r(), g(), b() {} 39 | TRGB(T _r, T _g, T _b) : r(_r), g(_g), b(_b) {} 40 | }; 41 | template struct TRGBA { 42 | T r, g, b, a; 43 | 44 | TRGBA() : r(), g(), b(), a() {} 45 | TRGBA(T _r, T _g, T _b, T _a) : r(_r), g(_g), b(_b), a(_a) {} 46 | }; 47 | 48 | using Ru8 = TR; 49 | using Ri16 = TR; 50 | using Rf16 = TR; 51 | using Rf32 = TR; 52 | 53 | using RGu8 = TRG; 54 | using RGi16 = TRG; 55 | using RGf16 = TRG; 56 | using RGf32 = TRG; 57 | 58 | using RGBu8 = TRGB; 59 | using RGBi16 = TRGB; 60 | using RGBf16 = TRGB; 61 | using RGBf32 = TRGB; 62 | using RGBAu8 = TRGBA; 63 | 64 | using RGBAi16 = TRGBA; 65 | using RGBAf16 = TRGBA; 66 | using RGBAf32 = TRGBA; 67 | 68 | 69 | template struct GetPixelFormat; 70 | #define Def(T, E) template<> struct GetPixelFormat { static const fcPixelFormat value = E; static const char* getName() { return #T; } }; 71 | Def(Ru8, fcPixelFormat_Ru8) 72 | Def(RGu8, fcPixelFormat_RGu8) 73 | Def(RGBu8, fcPixelFormat_RGBu8) 74 | Def(RGBAu8, fcPixelFormat_RGBAu8) 75 | Def(Ri16, fcPixelFormat_Ri16) 76 | Def(RGi16, fcPixelFormat_RGi16) 77 | Def(RGBi16, fcPixelFormat_RGBi16) 78 | Def(RGBAi16, fcPixelFormat_RGBAi16) 79 | Def(Rf16, fcPixelFormat_Rf16) 80 | Def(RGf16, fcPixelFormat_RGf16) 81 | Def(RGBf16, fcPixelFormat_RGBf16) 82 | Def(RGBAf16, fcPixelFormat_RGBAf16) 83 | Def(Rf32, fcPixelFormat_Rf32) 84 | Def(RGf32, fcPixelFormat_RGf32) 85 | Def(RGBf32, fcPixelFormat_RGBf32) 86 | Def(RGBAf32, fcPixelFormat_RGBAf32) 87 | #undef def 88 | 89 | template void CreateVideoData(T *rgba, int width, int height, int frame); 90 | void CreateAudioData(float *samples, int num_samples, double t, float scale); 91 | 92 | bool InitializeD3D11(); 93 | -------------------------------------------------------------------------------- /Plugin/Test/WaveTest.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TestCommon.h" 3 | 4 | void WaveTest(int bits) 5 | { 6 | const int SamplingRate = 48000; 7 | const int DurationInSeconds = 10; 8 | 9 | char filename[32]; 10 | sprintf(filename, "test%dbits.wav", bits); 11 | 12 | fcWaveConfig conf; 13 | conf.sample_rate = SamplingRate; 14 | conf.num_channels = 1; 15 | conf.bits_per_sample = bits; 16 | fcStream *fstream = fcCreateFileStream(filename); 17 | fcIWaveContext *ctx = fcWaveCreateContext(&conf); 18 | fcWaveAddOutputStream(ctx, fstream); 19 | 20 | 21 | // add audio frames 22 | { 23 | RawVector audio_sample(SamplingRate); 24 | fcTime t = 0; 25 | while (t < (double)DurationInSeconds) { 26 | CreateAudioData(audio_sample.data(), (int)audio_sample.size(), t, 1.0f); 27 | fcWaveAddAudioSamples(ctx, audio_sample.data(), (int)audio_sample.size()); 28 | t += 1.0; 29 | } 30 | } 31 | 32 | fcReleaseContext(ctx); 33 | fcReleaseStream(fstream); 34 | } 35 | 36 | void WaveTest() 37 | { 38 | if (!fcWaveIsSupported()) { 39 | printf("WaveTest: wave is not supported\n"); 40 | return; 41 | } 42 | WaveTest(8); 43 | WaveTest(16); 44 | WaveTest(24); 45 | } 46 | -------------------------------------------------------------------------------- /Plugin/Test/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | -------------------------------------------------------------------------------- /Plugin/Test/pch.h: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | #pragma warning(disable: 4190) 3 | #define _CRT_SECURE_NO_WARNINGS 4 | #endif 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | -------------------------------------------------------------------------------- /Plugin/build.bat: -------------------------------------------------------------------------------- 1 | call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" 2 | msbuild fccore.sln /t:Build /p:Configuration=Master /p:Platform=x64 /m /nologo 3 | msbuild fccore.sln /t:Build /p:Configuration=Master /p:Platform=Win32 /m /nologo 4 | -------------------------------------------------------------------------------- /Plugin/cmake/AddPlugin.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") 2 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") 3 | 4 | if (NOT CMAKE_BUILD_TYPE) 5 | set(CMAKE_BUILD_TYPE "Release" CACHE PATH "" FORCE) 6 | endif() 7 | if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 8 | set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/dist" CACHE PATH "" FORCE) 9 | endif() 10 | 11 | if(APPLE) 12 | set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") 13 | option(ENABLE_OSX_BUNDLE "Build bundle." ON) 14 | set(CMAKE_MACOSX_RPATH ON) 15 | 16 | if(ENABLE_OSX_BUNDLE) 17 | set(CMAKE_SKIP_RPATH ON) 18 | else() 19 | set(CMAKE_SKIP_RPATH OFF) 20 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) 21 | endif() 22 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") 23 | option(ENABLE_LINUX_USE_LINK_PATH "" ON) 24 | 25 | if(ENABLE_LINUX_USE_LINK_PATH) 26 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) 27 | endif() 28 | endif() 29 | option(ENABLE_DEPLOY "Copy built binaries to plugins directory." ON) 30 | 31 | 32 | function(add_plugin name) 33 | cmake_parse_arguments(arg "" "PLUGINS_DIR" "SOURCES" ${ARGN}) 34 | 35 | if(ENABLE_OSX_BUNDLE) 36 | add_library(${name} MODULE ${arg_SOURCES}) 37 | set_target_properties(${name} PROPERTIES BUNDLE ON) 38 | else() 39 | add_library(${name} SHARED ${arg_SOURCES}) 40 | endif() 41 | 42 | if(ENABLE_DEPLOY) 43 | if(ENABLE_OSX_BUNDLE) 44 | SET(target_filename "${name}.bundle") 45 | else() 46 | SET(target_filename $) 47 | endif() 48 | add_custom_target("Deploy${name}" ALL 49 | COMMAND rm -rf ${arg_PLUGINS_DIR}/${target_filename} 50 | COMMAND cp -r ${target_filename} ${arg_PLUGINS_DIR} 51 | DEPENDS ${name} 52 | ) 53 | endif() 54 | endfunction() 55 | -------------------------------------------------------------------------------- /Plugin/cmake/FindFLAC.cmake: -------------------------------------------------------------------------------- 1 | set(LIBRARY_PATHS 2 | /usr/lib 3 | /usr/local/lib 4 | ${FLAC_DIR}/lib 5 | ) 6 | 7 | find_path(FLAC_INCLUDE_DIR 8 | FLAC/all.h 9 | PATHS ${FLAC_DIR}/include 10 | ) 11 | 12 | find_library(FLAC_LIBRARY 13 | NAMES FLAC 14 | PATHS ${LIBRARY_PATHS} 15 | ) 16 | 17 | mark_as_advanced(FLAC_INCLUDE_DIR) 18 | mark_as_advanced(FLAC_LIBRARY) 19 | 20 | find_package_handle_standard_args("FLAC" 21 | DEFAULT_MSG 22 | FLAC_LIBRARY 23 | FLAC_INCLUDE_DIR 24 | ) 25 | -------------------------------------------------------------------------------- /Plugin/cmake/FindOgg.cmake: -------------------------------------------------------------------------------- 1 | set(LIBRARY_PATHS 2 | /usr/lib 3 | /usr/local/lib 4 | ${OGG_DIR}/lib 5 | ) 6 | 7 | find_path(OGG_INCLUDE_DIR 8 | ogg/ogg.h 9 | PATHS ${OGG_DIR}/include 10 | ) 11 | 12 | find_library(OGG_LIBRARY 13 | NAMES ogg 14 | PATHS ${LIBRARY_PATHS} 15 | ) 16 | 17 | mark_as_advanced(OGG_INCLUDE_DIR) 18 | mark_as_advanced(OGG_LIBRARY) 19 | 20 | find_package_handle_standard_args("OGG" 21 | DEFAULT_MSG 22 | OGG_LIBRARY 23 | OGG_INCLUDE_DIR 24 | ) 25 | -------------------------------------------------------------------------------- /Plugin/cmake/FindOpenEXR.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2016 Pixar 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "Apache License") 5 | # with the following modification; you may not use this file except in 6 | # compliance with the Apache License and the following modification to it: 7 | # Section 6. Trademarks. is deleted and replaced with: 8 | # 9 | # 6. Trademarks. This License does not grant permission to use the trade 10 | # names, trademarks, service marks, or product names of the Licensor 11 | # and its affiliates, except as required to comply with Section 4(c) of 12 | # the License and to reproduce the content of the NOTICE file. 13 | # 14 | # You may obtain a copy of the Apache License at 15 | # 16 | # http://www.apache.org/licenses/LICENSE-2.0 17 | # 18 | # Unless required by applicable law or agreed to in writing, software 19 | # distributed under the Apache License with the above modification is 20 | # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21 | # KIND, either express or implied. See the Apache License for the specific 22 | # language governing permissions and limitations under the Apache License. 23 | # 24 | 25 | if (APPLE) 26 | find_path(OPENEXR_LIBRARY_DIR 27 | libHalf.dylib 28 | HINTS 29 | "${OPENEXR_LOCATION}" 30 | "$ENV{OPENEXR_LOCATION}" 31 | "${OPENEXR_BASE_DIR}" 32 | PATH_SUFFIXES 33 | lib/ 34 | DOC 35 | "OpenEXR library path" 36 | ) 37 | elseif (UNIX) 38 | find_path(OPENEXR_LIBRARY_DIR 39 | libHalf.so 40 | HINTS 41 | "${OPENEXR_LOCATION}" 42 | "$ENV{OPENEXR_LOCATION}" 43 | "${OPENEXR_BASE_DIR}" 44 | PATH_SUFFIXES 45 | lib/ 46 | DOC 47 | "OpenEXR library path" 48 | ) 49 | elseif (WIN32) 50 | find_path(OPENEXR_LIBRARY_DIR 51 | Half.lib 52 | HINTS 53 | "${OPENEXR_LOCATION}" 54 | "$ENV{OPENEXR_LOCATION}" 55 | "${OPENEXR_BASE_DIR}" 56 | PATH_SUFFIXES 57 | lib/ 58 | DOC 59 | "OpenEXR library path" 60 | ) 61 | endif() 62 | mark_as_advanced(OPENEXR_LIBRARY_DIR) 63 | 64 | find_path(OPENEXR_INCLUDE_DIR 65 | OpenEXR/half.h 66 | HINTS 67 | "${OPENEXR_LOCATION}" 68 | "$ENV{OPENEXR_LOCATION}" 69 | "${OPENEXR_BASE_DIR}" 70 | PATH_SUFFIXES 71 | include/ 72 | DOC 73 | "OpenEXR headers path" 74 | ) 75 | 76 | if(OPENEXR_INCLUDE_DIR AND EXISTS "${OPENEXR_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h") 77 | file(STRINGS 78 | ${OPENEXR_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h 79 | TMP 80 | REGEX "#define OPENEXR_VERSION_STRING.*$") 81 | string(REGEX MATCHALL "[0-9.]+" OPENEXR_VERSION ${TMP}) 82 | mark_as_advanced(OPENEXR_INCLUDE_DIR) 83 | endif() 84 | 85 | 86 | foreach(OPENEXR_LIB 87 | Half 88 | Iex 89 | IexMath 90 | Imath 91 | IlmImf 92 | IlmThread 93 | ) 94 | 95 | find_library(OPENEXR_${OPENEXR_LIB}_LIBRARY 96 | ${OPENEXR_LIB} 97 | HINTS 98 | "${OPENEXR_LOCATION}" 99 | "$ENV{OPENEXR_LOCATION}" 100 | "${OPENEXR_BASE_DIR}" 101 | PATH_SUFFIXES 102 | lib/ 103 | DOC 104 | "OPENEXR's ${OPENEXR_LIB} library path" 105 | ) 106 | mark_as_advanced(OPENEXR_${OPENEXR_LIB}_LIBRARY) 107 | 108 | if(OPENEXR_${OPENEXR_LIB}_LIBRARY) 109 | list(APPEND OPENEXR_LIBRARIES ${OPENEXR_${OPENEXR_LIB}_LIBRARY}) 110 | endif() 111 | endforeach(OPENEXR_LIB) 112 | 113 | # So #include works 114 | list(APPEND OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR}) 115 | list(APPEND OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR}/OpenEXR) 116 | 117 | include(FindPackageHandleStandardArgs) 118 | find_package_handle_standard_args(OpenEXR 119 | REQUIRED_VARS 120 | OPENEXR_INCLUDE_DIRS 121 | OPENEXR_LIBRARY_DIR 122 | VERSION_VAR 123 | OPENEXR_VERSION 124 | ) 125 | -------------------------------------------------------------------------------- /Plugin/cmake/FindOpus.cmake: -------------------------------------------------------------------------------- 1 | set(LIBRARY_PATHS 2 | /usr/lib 3 | /usr/local/lib 4 | ${OPUS_DIR}/lib 5 | ) 6 | 7 | find_path(OPUS_INCLUDE_DIR 8 | opus/opus.h 9 | PATHS ${OPUS_DIR}/include 10 | ) 11 | 12 | find_library(OPUS_LIBRARY 13 | NAMES opus 14 | PATHS ${LIBRARY_PATHS} 15 | ) 16 | 17 | mark_as_advanced(OPUS_INCLUDE_DIR) 18 | mark_as_advanced(OPUS_LIBRARY) 19 | 20 | find_package_handle_standard_args("OPUS" 21 | DEFAULT_MSG 22 | OPUS_LIBRARY 23 | OPUS_INCLUDE_DIR 24 | ) 25 | -------------------------------------------------------------------------------- /Plugin/cmake/FindVPX.cmake: -------------------------------------------------------------------------------- 1 | set(LIBRARY_PATHS 2 | /usr/lib 3 | /usr/local/lib 4 | ${VPX_DIR}/lib 5 | ) 6 | 7 | find_path(VPX_INCLUDE_DIR 8 | vpx/vpx_codec.h 9 | PATHS ${VPX_DIR}/include 10 | ) 11 | 12 | find_library(VPX_LIBRARY 13 | NAMES vpx 14 | PATHS ${LIBRARY_PATHS} 15 | ) 16 | 17 | mark_as_advanced(VPX_INCLUDE_DIR) 18 | mark_as_advanced(VPX_LIBRARY) 19 | 20 | find_package_handle_standard_args("VPX" 21 | DEFAULT_MSG 22 | VPX_LIBRARY 23 | VPX_INCLUDE_DIR 24 | ) 25 | -------------------------------------------------------------------------------- /Plugin/cmake/FindVorbis.cmake: -------------------------------------------------------------------------------- 1 | set(LIBRARY_PATHS 2 | /usr/lib 3 | /usr/local/lib 4 | ${VORBIS_DIR}/lib 5 | ) 6 | 7 | find_path(VORBIS_INCLUDE_DIR 8 | vorbis/codec.h 9 | PATHS ${VORBIS_DIR}/include 10 | ) 11 | foreach(VORBIS_LIB 12 | vorbis 13 | vorbisenc 14 | vorbisfile 15 | ) 16 | find_library(${VORBIS_LIB}_LIBRARY 17 | ${VORBIS_LIB} 18 | PATHS ${LIBRARY_PATHS} 19 | ) 20 | mark_as_advanced(${VORBIS_LIB}_LIBRARY) 21 | if(${VORBIS_LIB}_LIBRARY) 22 | list(APPEND VORBIS_LIBRARIES ${${VORBIS_LIB}_LIBRARY}) 23 | endif() 24 | endforeach(VORBIS_LIB) 25 | 26 | mark_as_advanced(VORBIS_INCLUDE_DIR) 27 | 28 | find_package_handle_standard_args("VORBIS" 29 | DEFAULT_MSG 30 | VORBIS_LIBRARY 31 | VORBIS_INCLUDE_DIR 32 | ) 33 | -------------------------------------------------------------------------------- /Plugin/cmake/FindWEBM.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_PREFIX_PATH 2 | /usr/lib 3 | /usr/local/lib 4 | ${WEBM_DIR}/lib 5 | ) 6 | 7 | find_path(WEBM_INCLUDE_DIR 8 | mkvparser.hpp 9 | PATHS ${WEBM_DIR}/include 10 | ) 11 | 12 | find_library(WEBM_LIBRARY 13 | NAMES webm 14 | ) 15 | 16 | mark_as_advanced(WEBM_INCLUDE_DIR) 17 | mark_as_advanced(WEBM_LIBRARY) 18 | 19 | include(FindPackageHandleStandardArgs) 20 | find_package_handle_standard_args("WEBM" 21 | DEFAULT_MSG 22 | WEBM_LIBRARY 23 | WEBM_INCLUDE_DIR 24 | ) 25 | -------------------------------------------------------------------------------- /Plugin/cmake/FindYUV.cmake: -------------------------------------------------------------------------------- 1 | set(LIBRARY_PATHS 2 | /usr/lib 3 | /usr/local/lib 4 | ${YUV_DIR}/lib 5 | ) 6 | 7 | find_path(YUV_INCLUDE_DIR 8 | libyuv.h 9 | PATHS ${YUV_DIR}/include 10 | ) 11 | 12 | find_library(YUV_LIBRARY 13 | NAMES yuv 14 | PATHS ${LIBRARY_PATHS} 15 | ) 16 | 17 | mark_as_advanced(YUV_INCLUDE_DIR) 18 | mark_as_advanced(YUV_LIBRARY) 19 | 20 | find_package_handle_standard_args("YUV" 21 | DEFAULT_MSG 22 | YUV_LIBRARY 23 | YUV_INCLUDE_DIR 24 | ) 25 | -------------------------------------------------------------------------------- /Plugin/cmake/ISPC.cmake: -------------------------------------------------------------------------------- 1 | include(CMakeParseArguments) 2 | 3 | option(ENABLE_ISPC "Use Intel ISPC to generate SIMDified code. It can significantly boost performance." ON) 4 | set(ISPC "/usr/local/bin/ispc" CACHE PATH "Path to Intel ISPC") 5 | mark_as_advanced(FORCE ISPC) 6 | 7 | function(setup_ispc) 8 | if(EXISTS ${ISPC}) 9 | return() 10 | endif() 11 | 12 | set(ISPC_VERSION 1.9.1) 13 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 14 | set(ISPC_DIR "ispc-v${ISPC_VERSION}-linux") 15 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") 16 | set(ISPC_DIR "ispc-v${ISPC_VERSION}-osx") 17 | elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") 18 | set(ISPC_DIR "ispc-v${ISPC_VERSION}-windows-vs2015") 19 | endif() 20 | set(ISPC "${CMAKE_BINARY_DIR}/${ISPC_DIR}/ispc" CACHE PATH "" FORCE) 21 | 22 | set(ISPC_ARCHIVE_FILE "${ISPC_DIR}.tar.gz") 23 | set(ISPC_ARCHIVE_URL "http://downloads.sourceforge.net/project/ispcmirror/v${ISPC_VERSION}/${ISPC_ARCHIVE_FILE}") 24 | set(ISPC_ARCHIVE_PATH "${CMAKE_BINARY_DIR}/${ISPC_ARCHIVE_FILE}") 25 | if(NOT EXISTS ${ISPC_ARCHIVE_PATH}) 26 | file(DOWNLOAD ${ISPC_ARCHIVE_URL} ${ISPC_ARCHIVE_PATH} SHOW_PROGRESS) 27 | endif() 28 | execute_process( 29 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 30 | COMMAND tar -xf ${ISPC_ARCHIVE_PATH} 31 | ) 32 | endfunction() 33 | 34 | # e.g: 35 | #add_ispc_targets( 36 | # SOURCES "src1.ispc" "src2.ispc" 37 | # HEADERS "header1.h" "header2.h" 38 | # OUTDIR "path/to/outputs") 39 | function(add_ispc_targets) 40 | cmake_parse_arguments(arg "" "OUTDIR" "SOURCES;HEADERS" ${ARGN}) 41 | 42 | foreach(source ${arg_SOURCES}) 43 | get_filename_component(name ${source} NAME_WE) 44 | set(header "${arg_OUTDIR}/${name}.h") 45 | set(object "${arg_OUTDIR}/${name}${CMAKE_CXX_OUTPUT_EXTENSION}") 46 | set(objects 47 | ${object} 48 | "${arg_OUTDIR}/${name}_sse4${CMAKE_CXX_OUTPUT_EXTENSION}" 49 | "${arg_OUTDIR}/${name}_avx${CMAKE_CXX_OUTPUT_EXTENSION}" 50 | ) 51 | set(outputs ${header} ${objects}) 52 | add_custom_command( 53 | OUTPUT ${outputs} 54 | COMMAND ${ISPC} ${source} -o ${object} -h ${header} --pic --target=sse4,avx --arch=x86-64 --opt=fast-masked-vload --opt=fast-math 55 | DEPENDS ${source} ${arg_HEADERS} 56 | ) 57 | 58 | list(APPEND _ispc_headers ${header}) 59 | list(APPEND _ispc_objects ${objects}) 60 | list(APPEND _ispc_outputs ${outputs}) 61 | endforeach() 62 | 63 | set(_ispc_headers ${_ispc_headers} PARENT_SCOPE) 64 | set(_ispc_objects ${_ispc_objects} PARENT_SCOPE) 65 | set(_ispc_outputs ${_ispc_outputs} PARENT_SCOPE) 66 | 67 | execute_process(COMMAND mkdir -p ${arg_OUTDIR}) 68 | foreach(f ${_ispc_outputs}) 69 | if(NOT EXISTS ${f}) 70 | execute_process(COMMAND touch -t 200001010000 ${f}) 71 | endif() 72 | endforeach() 73 | endfunction() 74 | -------------------------------------------------------------------------------- /Plugin/external/7z/7za.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Plugin/external/7z/7za.exe -------------------------------------------------------------------------------- /Plugin/external/PluginAPI/IUnityGraphics.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IUnityInterface.h" 3 | 4 | typedef enum UnityGfxRenderer 5 | { 6 | //kUnityGfxRendererOpenGL = 0, // Legacy OpenGL, removed 7 | kUnityGfxRendererD3D9 = 1, // Direct3D 9 8 | kUnityGfxRendererD3D11 = 2, // Direct3D 11 9 | kUnityGfxRendererGCM = 3, // PlayStation 3 10 | kUnityGfxRendererNull = 4, // "null" device (used in batch mode) 11 | kUnityGfxRendererOpenGLES20 = 8, // OpenGL ES 2.0 12 | kUnityGfxRendererOpenGLES30 = 11, // OpenGL ES 3.0 13 | kUnityGfxRendererGXM = 12, // PlayStation Vita 14 | kUnityGfxRendererPS4 = 13, // PlayStation 4 15 | kUnityGfxRendererXboxOne = 14, // Xbox One 16 | kUnityGfxRendererMetal = 16, // iOS Metal 17 | kUnityGfxRendererOpenGLCore = 17, // OpenGL core 18 | kUnityGfxRendererD3D12 = 18, // Direct3D 12 19 | kUnityGfxRendererVulkan = 21, // Vulkan 20 | } UnityGfxRenderer; 21 | 22 | typedef enum UnityGfxDeviceEventType 23 | { 24 | kUnityGfxDeviceEventInitialize = 0, 25 | kUnityGfxDeviceEventShutdown = 1, 26 | kUnityGfxDeviceEventBeforeReset = 2, 27 | kUnityGfxDeviceEventAfterReset = 3, 28 | } UnityGfxDeviceEventType; 29 | 30 | typedef void (UNITY_INTERFACE_API * IUnityGraphicsDeviceEventCallback)(UnityGfxDeviceEventType eventType); 31 | 32 | // Should only be used on the rendering thread unless noted otherwise. 33 | UNITY_DECLARE_INTERFACE(IUnityGraphics) 34 | { 35 | UnityGfxRenderer(UNITY_INTERFACE_API * GetRenderer)(); // Thread safe 36 | 37 | // This callback will be called when graphics device is created, destroyed, reset, etc. 38 | // It is possible to miss the kUnityGfxDeviceEventInitialize event in case plugin is loaded at a later time, 39 | // when the graphics device is already created. 40 | void(UNITY_INTERFACE_API * RegisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback); 41 | void(UNITY_INTERFACE_API * UnregisterDeviceEventCallback)(IUnityGraphicsDeviceEventCallback callback); 42 | }; 43 | UNITY_REGISTER_INTERFACE_GUID(0x7CBA0A9CA4DDB544ULL, 0x8C5AD4926EB17B11ULL, IUnityGraphics) 44 | 45 | 46 | // Certain Unity APIs (GL.IssuePluginEvent, CommandBuffer.IssuePluginEvent) can callback into native plugins. 47 | // Provide them with an address to a function of this signature. 48 | typedef void (UNITY_INTERFACE_API * UnityRenderingEvent)(int eventId); 49 | -------------------------------------------------------------------------------- /Plugin/external/PluginAPI/IUnityGraphicsD3D11.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IUnityInterface.h" 3 | 4 | struct RenderSurfaceBase; 5 | typedef struct RenderSurfaceBase* UnityRenderBuffer; 6 | 7 | // Should only be used on the rendering thread unless noted otherwise. 8 | UNITY_DECLARE_INTERFACE(IUnityGraphicsD3D11) 9 | { 10 | ID3D11Device* (UNITY_INTERFACE_API * GetDevice)(); 11 | 12 | ID3D11Resource* (UNITY_INTERFACE_API * TextureFromRenderBuffer)(UnityRenderBuffer buffer); 13 | }; 14 | UNITY_REGISTER_INTERFACE_GUID(0xAAB37EF87A87D748ULL, 0xBF76967F07EFB177ULL, IUnityGraphicsD3D11) 15 | -------------------------------------------------------------------------------- /Plugin/external/PluginAPI/IUnityGraphicsD3D9.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IUnityInterface.h" 3 | 4 | // Should only be used on the rendering thread unless noted otherwise. 5 | UNITY_DECLARE_INTERFACE(IUnityGraphicsD3D9) 6 | { 7 | IDirect3D9* (UNITY_INTERFACE_API * GetD3D)(); 8 | IDirect3DDevice9* (UNITY_INTERFACE_API * GetDevice)(); 9 | }; 10 | UNITY_REGISTER_INTERFACE_GUID(0xE90746A523D53C4CULL, 0xAC825B19B6F82AC3ULL, IUnityGraphicsD3D9) 11 | -------------------------------------------------------------------------------- /Plugin/external/PluginAPI/IUnityGraphicsMetal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "IUnityInterface.h" 3 | 4 | #ifndef __OBJC__ 5 | #error metal plugin is objc code. 6 | #endif 7 | #ifndef __clang__ 8 | #error only clang compiler is supported. 9 | #endif 10 | 11 | @class NSBundle; 12 | @protocol MTLDevice; 13 | @protocol MTLCommandBuffer; 14 | @protocol MTLCommandEncoder; 15 | @protocol MTLTexture; 16 | 17 | struct RenderSurfaceBase; 18 | typedef struct RenderSurfaceBase* UnityRenderBuffer; 19 | 20 | // Should only be used on the rendering thread unless noted otherwise. 21 | UNITY_DECLARE_INTERFACE(IUnityGraphicsMetal) 22 | { 23 | NSBundle* (UNITY_INTERFACE_API * MetalBundle)(); 24 | id(UNITY_INTERFACE_API * MetalDevice)(); 25 | 26 | id(UNITY_INTERFACE_API * CurrentCommandBuffer)(); 27 | 28 | // for custom rendering support there are two scenarios: 29 | // you want to use current in-flight MTLCommandEncoder (NB: it might be nil) 30 | id(UNITY_INTERFACE_API * CurrentCommandEncoder)(); 31 | // or you might want to create your own encoder. 32 | // In that case you should end unity's encoder before creating your own and end yours before returning control to unity 33 | void(UNITY_INTERFACE_API * EndCurrentCommandEncoder)(); 34 | 35 | // converting trampoline UnityRenderBufferHandle into native RenderBuffer 36 | UnityRenderBuffer(UNITY_INTERFACE_API * RenderBufferFromHandle)(void* bufferHandle); 37 | 38 | // access to RenderBuffer's texure 39 | // NB: you pass here *native* RenderBuffer, acquired by calling (C#) RenderBuffer.GetNativeRenderBufferPtr 40 | // AAResolvedTextureFromRenderBuffer will return nil in case of non-AA RenderBuffer or if called for depth RenderBuffer 41 | // StencilTextureFromRenderBuffer will return nil in case of no-stencil RenderBuffer or if called for color RenderBuffer 42 | id(UNITY_INTERFACE_API * TextureFromRenderBuffer)(UnityRenderBuffer buffer); 43 | id(UNITY_INTERFACE_API * AAResolvedTextureFromRenderBuffer)(UnityRenderBuffer buffer); 44 | id(UNITY_INTERFACE_API * StencilTextureFromRenderBuffer)(UnityRenderBuffer buffer); 45 | }; 46 | UNITY_REGISTER_INTERFACE_GUID(0x992C8EAEA95811E5ULL, 0x9A62C4B5B9876117ULL, IUnityGraphicsMetal) 47 | -------------------------------------------------------------------------------- /Plugin/fccore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26228.9 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fccore", "fccore.vcxproj", "{08361722-5520-47AC-A0C2-31E8A062B73F}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{FECF9257-E769-403F-89EC-1767901184CD}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "setup", "setup.vcxproj", "{1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test\Test.vcxproj", "{2E766DA9-F367-4363-A7D7-05EE6C11F5D1}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Win32 = Debug|Win32 17 | Debug|x64 = Debug|x64 18 | Master|Win32 = Master|Win32 19 | Master|x64 = Master|x64 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {08361722-5520-47AC-A0C2-31E8A062B73F}.Debug|Win32.ActiveCfg = Debug|Win32 23 | {08361722-5520-47AC-A0C2-31E8A062B73F}.Debug|Win32.Build.0 = Debug|Win32 24 | {08361722-5520-47AC-A0C2-31E8A062B73F}.Debug|x64.ActiveCfg = Debug|x64 25 | {08361722-5520-47AC-A0C2-31E8A062B73F}.Debug|x64.Build.0 = Debug|x64 26 | {08361722-5520-47AC-A0C2-31E8A062B73F}.Master|Win32.ActiveCfg = Master|Win32 27 | {08361722-5520-47AC-A0C2-31E8A062B73F}.Master|Win32.Build.0 = Master|Win32 28 | {08361722-5520-47AC-A0C2-31E8A062B73F}.Master|x64.ActiveCfg = Master|x64 29 | {08361722-5520-47AC-A0C2-31E8A062B73F}.Master|x64.Build.0 = Master|x64 30 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}.Debug|Win32.Build.0 = Debug|Win32 32 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}.Debug|x64.ActiveCfg = Debug|x64 33 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}.Debug|x64.Build.0 = Debug|x64 34 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}.Master|Win32.ActiveCfg = Master|Win32 35 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}.Master|Win32.Build.0 = Master|Win32 36 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}.Master|x64.ActiveCfg = Master|x64 37 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D}.Master|x64.Build.0 = Master|x64 38 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1}.Debug|Win32.Build.0 = Debug|Win32 40 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1}.Debug|x64.ActiveCfg = Debug|x64 41 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1}.Debug|x64.Build.0 = Debug|x64 42 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1}.Master|Win32.ActiveCfg = Master|Win32 43 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1}.Master|Win32.Build.0 = Master|Win32 44 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1}.Master|x64.ActiveCfg = Master|x64 45 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1}.Master|x64.Build.0 = Master|x64 46 | EndGlobalSection 47 | GlobalSection(SolutionProperties) = preSolution 48 | HideSolutionNode = FALSE 49 | EndGlobalSection 50 | GlobalSection(NestedProjects) = preSolution 51 | {2E766DA9-F367-4363-A7D7-05EE6C11F5D1} = {FECF9257-E769-403F-89EC-1767901184CD} 52 | EndGlobalSection 53 | EndGlobal 54 | -------------------------------------------------------------------------------- /Plugin/fccore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(ENABLE_ISPC) 2 | setup_ispc() 3 | set(FCISPC_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}/ISPC) 4 | set(FCISPC_SOURCES 5 | "${CMAKE_CURRENT_SOURCE_DIR}/Foundation/ConvertKernel.ispc" 6 | ) 7 | add_ispc_targets(SOURCES ${FCISPC_SOURCES} OUTDIR ${FCISPC_OUTDIR}) 8 | set(FCISPC_OUTPUTS ${_ispc_outputs}) 9 | endif() 10 | 11 | file(GLOB FC_SOURCES 12 | *.cpp 13 | Foundation/*.cpp 14 | Encoder/Audio/*.cpp 15 | Encoder/Image/*.cpp 16 | Encoder/MP4/*.cpp 17 | Encoder/WebM/*.cpp 18 | GraphicsDevice/*.cpp 19 | *.h 20 | Foundation/*.h 21 | Encoder/Audio/*.h 22 | Encoder/Image/*.h 23 | Encoder/MP4/*.h 24 | Encoder/WebM/*.h 25 | GraphicsDevice/*.h 26 | ) 27 | set(PLUGINS_DIR "${CMAKE_SOURCE_DIR}/../FrameCapturer/Assets/UTJ/FrameCapturer/Plugins/x86_64") 28 | add_plugin(fccore SOURCES ${FC_SOURCES} ${FCISPC_OUTPUTS} PLUGINS_DIR ${PLUGINS_DIR}) 29 | 30 | target_include_directories( 31 | fccore 32 | PRIVATE 33 | ${CMAKE_CURRENT_SOURCE_DIR} 34 | ${CMAKE_SOURCE_DIR}/external 35 | ${OPENEXR_INCLUDE_DIRS} 36 | ${YUV_INCLUDE_DIR} 37 | ${WEBM_INCLUDE_DIR} 38 | ${OGG_INCLUDE_DIR} 39 | ${VORBIS_INCLUDE_DIR} 40 | ${OPUS_INCLUDE_DIR} 41 | ${FLAC_INCLUDE_DIR} 42 | ) 43 | install(TARGETS fccore DESTINATION .) 44 | 45 | target_link_libraries(fccore 46 | pthread z ${OPENEXR_Half_LIBRARY} ${YUV_LIBRARY} 47 | ) 48 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 49 | target_link_libraries(fccore dl) 50 | endif() 51 | 52 | if(ENABLE_ISPC) 53 | add_definitions(-DfcEnableISPC) 54 | target_include_directories(fccore PRIVATE ${FCISPC_OUTDIR}) 55 | endif() 56 | 57 | if(FC_ENABLE_GIF) 58 | add_definitions(-DfcSupportGIF) 59 | endif() 60 | 61 | if(FC_ENABLE_PNG) 62 | add_definitions(-DfcSupportPNG) 63 | target_link_libraries(fccore ${PNG_LIBRARY}) 64 | endif() 65 | 66 | if(FC_ENABLE_EXR) 67 | add_definitions(-DfcSupportEXR) 68 | target_link_libraries(fccore ${OPENEXR_LIBRARIES}) 69 | endif() 70 | 71 | if(FC_ENABLE_WEBM) 72 | add_definitions(-DfcSupportWebM) 73 | target_link_libraries(fccore ${WEBM_LIBRARY}) 74 | if(FC_ENABLE_VPX) 75 | add_definitions(-DfcSupportVPX) 76 | target_link_libraries(fccore ${VPX_LIBRARY}) 77 | endif() 78 | if(FC_ENABLE_OPUS) 79 | add_definitions(-DfcSupportOpus) 80 | target_link_libraries(fccore ${OPUS_LIBRARY}) 81 | endif() 82 | endif() 83 | 84 | if(FC_ENABLE_MP4) 85 | add_definitions(-DfcSupportMP4) 86 | if(FC_ENABLE_FAAC) 87 | add_definitions(-DfcSupportAAC_FAAC) 88 | endif() 89 | if(FC_ENABLE_OPENH264) 90 | add_definitions(-DfcSupportH264_OpenH264) 91 | endif() 92 | endif() 93 | if(FC_ENABLE_WAVE) 94 | add_definitions(-DfcSupportWave) 95 | endif() 96 | 97 | if(FC_ENABLE_VORBIS) 98 | add_definitions(-DfcSupportVorbis) 99 | target_link_libraries(fccore ${OGG_LIBRARY} ${VORBIS_LIBRARIES}) 100 | if(FC_ENABLE_FLAC) 101 | add_definitions(-DfcSupportFlac) 102 | target_link_libraries(fccore ${FLAC_LIBRARY}) 103 | endif() 104 | endif() 105 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/Audio/fcFlacContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class fcIFlacContext : public fcContextBase 4 | { 5 | public: 6 | virtual void addOutputStream(fcStream *s) = 0; 7 | virtual bool addSamples(const float *samples, int num_samples) = 0; 8 | }; 9 | fcIFlacContext* fcFlacCreateContextImpl(const fcFlacConfig *conf); 10 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/Audio/fcOggContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class fcIOggContext : public fcContextBase 4 | { 5 | public: 6 | virtual void addOutputStream(fcStream *s) = 0; 7 | virtual bool addSamples(const float *samples, int num_samples) = 0; 8 | }; 9 | fcIOggContext* fcOggCreateContextImpl(const fcOggConfig *conf); 10 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/Audio/fcWaveContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class fcIWaveContext : public fcContextBase 4 | { 5 | public: 6 | virtual void addOutputStream(fcStream *s) = 0; 7 | virtual bool addSamples(const float *samples, int num_samples) = 0; 8 | }; 9 | fcIWaveContext* fcWaveCreateContextImpl(const fcWaveConfig *conf); 10 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/Image/fcExrContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class fcIExrContext : public fcContextBase 4 | { 5 | public: 6 | virtual bool beginFrame(const char *path, int width, int height) = 0; 7 | virtual bool addLayerTexture(void *tex, fcPixelFormat fmt, int channel, const char *name) = 0; 8 | virtual bool addLayerPixels(const void *pixels, fcPixelFormat fmt, int channel, const char *name) = 0; 9 | virtual bool endFrame() = 0; 10 | }; 11 | fcIExrContext* fcExrCreateContextImpl(const fcExrConfig *conf, fcIGraphicsDevice *dev); 12 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/Image/fcGifContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class fcIGifContext : public fcContextBase 4 | { 5 | public: 6 | virtual void addOutputStream(fcStream *s) = 0; 7 | virtual bool addFrameTexture(void *tex, fcPixelFormat fmt, fcTime timestamp = -1) = 0; 8 | virtual bool addFramePixels(const void *pixels, fcPixelFormat fmt, fcTime timestamp = -1) = 0; 9 | virtual void forceKeyframe() = 0; 10 | }; 11 | 12 | fcIGifContext* fcGifCreateContextImpl(const fcGifConfig &conf, fcIGraphicsDevice *dev); 13 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/Image/fcPngContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class fcIPngContext : public fcContextBase 4 | { 5 | public: 6 | virtual bool exportTexture(const char *path, void *tex, int width, int height, fcPixelFormat fmt, int num_channels) = 0; 7 | virtual bool exportPixels(const char *path, const void *pixels, int width, int height, fcPixelFormat fmt, int num_channels) = 0; 8 | }; 9 | 10 | fcIPngContext* fcPngCreateContextImpl(const fcPngConfig *conf, fcIGraphicsDevice *dev); -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcAACEncoder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | struct fcAACEncoderConfig 5 | { 6 | int sample_rate; 7 | int num_channels; 8 | fcBitrateMode bitrate_mode; 9 | int target_bitrate; 10 | }; 11 | 12 | 13 | struct fcAACFrame 14 | { 15 | struct PacketInfo 16 | { 17 | uint32_t size; 18 | double duration; 19 | double timestamp; 20 | }; 21 | 22 | Buffer data; 23 | RawVector packets; 24 | 25 | void clear() 26 | { 27 | data.clear(); 28 | packets.clear(); 29 | } 30 | 31 | // Body: [](const char *data, const fcAACFrame::PacketInfo& pinfo) -> void 32 | template 33 | void eachPackets(const Body& body) const 34 | { 35 | int total = 0; 36 | for (auto& p : packets) { 37 | body(&data[total], p); 38 | total += p.size; 39 | } 40 | } 41 | }; 42 | 43 | 44 | class fcIAACEncoder 45 | { 46 | public: 47 | virtual ~fcIAACEncoder() {} 48 | virtual const char* getEncoderInfo() = 0; 49 | virtual const Buffer& getDecoderSpecificInfo() = 0; 50 | virtual bool encode(fcAACFrame& dst, const float *samples, size_t num_samples) = 0; 51 | virtual bool flush(fcAACFrame& dst) = 0; 52 | }; 53 | 54 | bool fcLoadFAACModule(); 55 | 56 | fcIAACEncoder* fcCreateAACEncoderFAAC(const fcAACEncoderConfig& conf); 57 | fcIAACEncoder* fcCreateAACEncoderIntel(const fcAACEncoderConfig& conf); 58 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcAACEncoderIntel.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | #include "Foundation/fcFoundation.h" 4 | #include "GraphicsDevice/fcGraphicsDevice.h" 5 | #include "fcMP4Internal.h" 6 | #include "fcAACEncoder.h" 7 | 8 | #ifdef fcSupportAAC_Intel 9 | #include "IntelQSV/mfxaudio++.h" 10 | #ifdef _WIN32 11 | #pragma comment(lib, "libmfx.lib") 12 | #pragma comment(lib, "legacy_stdio_definitions.lib") 13 | #endif 14 | 15 | 16 | class fcAACEncoderIntel : public fcIAACEncoder 17 | { 18 | public: 19 | fcAACEncoderIntel(const fcAACEncoderConfig& conf); 20 | ~fcAACEncoderIntel() override; 21 | 22 | const char* getEncoderInfo() override; 23 | const Buffer& getDecoderSpecificInfo() override; 24 | bool encode(fcAACFrame& dst, const float *samples, size_t num_samples) override; 25 | bool flush(fcAACFrame& dst) override; 26 | 27 | bool isValid() { return m_encoder != nullptr; } 28 | 29 | private: 30 | fcAACEncoderConfig m_conf; 31 | void *m_handle; 32 | unsigned long m_num_read_samples; 33 | unsigned long m_output_size; 34 | Buffer m_aac_tmp_buf; 35 | Buffer m_aac_header; 36 | RawVector m_tmp_data; 37 | 38 | std::unique_ptr m_session; 39 | std::unique_ptr m_encoder; 40 | }; 41 | 42 | 43 | fcAACEncoderIntel::fcAACEncoderIntel(const fcAACEncoderConfig& conf) 44 | { 45 | mfxStatus ret; 46 | m_session.reset(new MFXAudioSession()); 47 | ret = m_session->Init(MFX_IMPL_AUTO_ANY, nullptr); 48 | if (ret < 0) { 49 | m_session.reset(); 50 | return; 51 | } 52 | 53 | mfxAudioParam params; 54 | memset(¶ms, 0, sizeof(params)); 55 | params.mfx.CodecId = MFX_CODEC_AAC; 56 | params.mfx.CodecProfile = MFX_PROFILE_AAC_MAIN; 57 | params.mfx.Bitrate = conf.target_bitrate; 58 | params.mfx.SampleFrequency = conf.sample_rate; 59 | params.mfx.NumChannel = conf.num_channels; 60 | params.mfx.BitPerSample = 32; 61 | params.mfx.OutputFormat = MFX_AUDIO_AAC_ADTS; 62 | params.mfx.StereoMode = MFX_AUDIO_AAC_LR_STEREO; 63 | 64 | m_encoder.reset(new MFXAudioENCODE(*m_session)); 65 | ret = m_encoder->Init(¶ms); 66 | if (ret < 0) { 67 | m_encoder.reset(); 68 | } 69 | } 70 | 71 | fcAACEncoderIntel::~fcAACEncoderIntel() 72 | { 73 | m_encoder.reset(); 74 | m_session.reset(); 75 | } 76 | 77 | const char* fcAACEncoderIntel::getEncoderInfo() 78 | { 79 | return "Intel AAC Encoder"; 80 | } 81 | 82 | const Buffer& fcAACEncoderIntel::getDecoderSpecificInfo() 83 | { 84 | return m_aac_header; 85 | } 86 | 87 | bool fcAACEncoderIntel::encode(fcAACFrame& dst, const float *samples, size_t num_samples) 88 | { 89 | if (!isValid()) { return false; } 90 | 91 | mfxAudioFrame frame; 92 | mfxBitstream buffer_out; 93 | mfxSyncPoint syncp; 94 | mfxStatus ret; 95 | ret = m_encoder->EncodeFrameAsync(&frame, &buffer_out, &syncp); 96 | if (ret < 0) { return false; } 97 | 98 | return true; 99 | } 100 | 101 | bool fcAACEncoderIntel::flush(fcAACFrame& dst) 102 | { 103 | return false; 104 | } 105 | 106 | fcIAACEncoder* fcCreateAACEncoderIntel(const fcAACEncoderConfig& conf) 107 | { 108 | auto ret = new fcAACEncoderIntel(conf); 109 | if (!ret->isValid()) { 110 | delete ret; 111 | ret = nullptr; 112 | } 113 | return ret; 114 | } 115 | 116 | #else // fcSupportAAC_Intel 117 | 118 | fcIAACEncoder* fcCreateAACEncoderIntel(const fcAACEncoderConfig& conf) { return nullptr; } 119 | 120 | #endif // fcSupportAAC_Intel 121 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcH264Encoder.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | #include "Foundation/fcFoundation.h" 4 | #include "GraphicsDevice/fcGraphicsDevice.h" 5 | #include "fcMP4Internal.h" 6 | #include "fcH264Encoder.h" 7 | 8 | void fcH264Frame::gatherNALInformation() 9 | { 10 | // gather NAL information 11 | static const char start_seq[] = { 0, 0, 1 }; // NAL start sequence 12 | char *beg = data.data(); 13 | char *end = beg + data.size(); 14 | for (;;) { 15 | auto *pos = std::search(beg, end, start_seq, start_seq + 3); 16 | if (pos == end) { break; } 17 | auto *next = std::search(pos + 1, end, start_seq, start_seq + 3); 18 | nal_sizes.push_back(int(next - pos)); 19 | beg = next; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcH264Encoder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | struct fcH264EncoderConfig 5 | { 6 | int width = 0; 7 | int height = 0; 8 | int target_framerate = 30; 9 | fcBitrateMode bitrate_mode = fcBitrateMode::CBR; 10 | int target_bitrate = 128000; 11 | }; 12 | 13 | 14 | enum fcH264FrameType 15 | { 16 | fcH264FrameType_UNKNOWN = 0, 17 | fcH264FrameType_I = 0x01, 18 | fcH264FrameType_P = 0x02, 19 | fcH264FrameType_B = 0x04, 20 | fcH264FrameType_S = 0x08, 21 | fcH264FrameType_REF = 0x10, 22 | fcH264FrameType_IDR = 0x20, 23 | }; 24 | 25 | enum fcH264NALType 26 | { 27 | fcH264NALType_UNKNOWN = 0, 28 | fcH264NALType_SLICE = 1, 29 | fcH264NALType_SLICE_DPA = 2, 30 | fcH264NALType_SLICE_DPB = 3, 31 | fcH264NALType_SLICE_DPC = 4, 32 | fcH264NALType_SLICE_IDR = 5, 33 | fcH264NALType_SEI = 6, 34 | fcH264NALType_SPS = 7, 35 | fcH264NALType_PPS = 8, 36 | fcH264NALType_AUD = 9, 37 | fcH264NALType_FILLER = 12, 38 | }; 39 | 40 | enum fcH264NALPriority 41 | { 42 | fcH264NALPriority_DISPOSABLE = 0, 43 | fcH264NALPriority_LOW = 1, 44 | fcH264NALPriority_HIGH = 2, 45 | fcH264NALPriority_HIGHEST = 3, 46 | }; 47 | 48 | struct fcH264NALHeader 49 | { 50 | uint8_t type : 5; // fcH264NALType 51 | uint8_t ref_idc : 2; 52 | uint8_t forbidden_zero_bit : 1; 53 | 54 | fcH264NALHeader() {} 55 | fcH264NALHeader(char c) { 56 | forbidden_zero_bit = (c >> 7) & 0x01; 57 | ref_idc = (c >> 5) & 0x03; 58 | type = c & 0x1f; 59 | } 60 | }; 61 | 62 | 63 | struct fcH264Frame 64 | { 65 | Buffer data; 66 | double timestamp = 0; 67 | int type = 0; // combination of fcH264FrameType 68 | RawVector nal_sizes; 69 | 70 | void clear() 71 | { 72 | timestamp = 0; 73 | type = 0; 74 | data.clear(); 75 | nal_sizes.clear(); 76 | } 77 | 78 | // Body: [](const char *nal_data, int nal_size) -> void 79 | template 80 | void eachNALs(const Body& body) const 81 | { 82 | int total = 0; 83 | for (int size : nal_sizes) { 84 | body(&data[total], size); 85 | total += size; 86 | } 87 | } 88 | 89 | void gatherNALInformation(); 90 | }; 91 | 92 | 93 | class fcIH264Encoder 94 | { 95 | public: 96 | virtual ~fcIH264Encoder() {} 97 | virtual const char* getEncoderInfo() = 0; 98 | virtual bool encode(fcH264Frame& dst, const void *image, fcPixelFormat fmt, fcTime timestamp, bool force_keyframe = false) = 0; 99 | virtual bool flush(fcH264Frame& dst) = 0; 100 | }; 101 | 102 | bool fcLoadOpenH264Module(); 103 | 104 | enum class fcHWEncoderDeviceType 105 | { 106 | Unknown, 107 | D3D9, 108 | D3D10, 109 | D3D11, 110 | D3D12, 111 | CUDA, 112 | }; 113 | 114 | fcIH264Encoder* fcCreateH264EncoderOpenH264(const fcH264EncoderConfig& conf); 115 | fcIH264Encoder* fcCreateH264EncoderNVIDIA(const fcH264EncoderConfig& conf, void *device, fcHWEncoderDeviceType type); 116 | fcIH264Encoder* fcCreateH264EncoderAMD(const fcH264EncoderConfig& conf, void *device, fcHWEncoderDeviceType type); 117 | fcIH264Encoder* fcCreateH264EncoderIntelHW(const fcH264EncoderConfig& conf, void *device, fcHWEncoderDeviceType type); 118 | fcIH264Encoder* fcCreateH264EncoderIntelSW(const fcH264EncoderConfig& conf); 119 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcMP4Context.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class fcIMP4Context : public fcContextBase 4 | { 5 | public: 6 | virtual bool isValid() const = 0; 7 | 8 | virtual const char* getVideoEncoderInfo() = 0; 9 | virtual const char* getAudioEncoderInfo() = 0; 10 | 11 | virtual void addOutputStream(fcStream *s) = 0; 12 | 13 | // assume texture format is RGBA8. 14 | // timestamp=-1 is treated as current time. 15 | virtual bool addVideoFrameTexture(void *tex, fcPixelFormat fmt, fcTime timestamp = -1) = 0; 16 | 17 | // assume pixel format is RGBA8 or I420 (color_space indicates) 18 | // timestamp=-1 is treated as current time. 19 | virtual bool addVideoFramePixels(const void *pixels, fcPixelFormat fmt, fcTime timestamp = -1) = 0; 20 | 21 | // timestamp=-1 is treated as current time. 22 | virtual bool addAudioSamples(const float *samples, int num_samples) = 0; 23 | }; 24 | 25 | #define fcMP4EachFunctions(Body)\ 26 | Body(fcMP4SetModulePathImpl)\ 27 | Body(fcMP4SetFAACPackagePathImpl)\ 28 | Body(fcMP4DownloadCodecBeginImpl)\ 29 | Body(fcMP4DownloadCodecGetStateImpl)\ 30 | Body(fcMP4CreateContextImpl)\ 31 | Body(fcMP4OSCreateContextImpl) 32 | 33 | void fcMP4SetModulePathImpl(const char *path); 34 | fcIMP4Context* fcMP4CreateContextImpl(fcMP4Config &conf, fcIGraphicsDevice*); 35 | bool fcMP4OSIsSupportedImpl(); 36 | fcIMP4Context* fcMP4OSCreateContextImpl(fcMP4Config &conf, fcIGraphicsDevice *dev, const char *path); 37 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcMP4Internal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | struct fcMP4FrameInfo 5 | { 6 | size_t size = 0; 7 | uint64_t file_offset = 0; 8 | uint64_t timestamp = 0; 9 | }; 10 | 11 | struct fcMP4OffsetValue 12 | { 13 | uint32_t count = 0; 14 | uint32_t value = 0; 15 | }; 16 | 17 | struct fcMP4SampleToChunk 18 | { 19 | uint32_t first_chunk_ID = 0; 20 | uint32_t samples_per_chunk = 0; 21 | uint32_t sample_description_ID = 0; 22 | }; 23 | 24 | const std::string& fcMP4GetModulePath(); 25 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcMP4Writer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | class fcMP4Writer 5 | { 6 | public: 7 | fcMP4Writer(BinaryStream *stream, const fcMP4Config &conf); 8 | virtual ~fcMP4Writer(); 9 | void addVideoFrame(const fcH264Frame& frame); // thread safe 10 | void AddAudioSamples(const fcAACFrame& frame); // thread safe 11 | void setAACEncoderInfo(const Buffer& aacheader); 12 | 13 | private: 14 | void mp4Begin(); 15 | void mp4End(); 16 | 17 | private: 18 | BinaryStream *m_stream = nullptr; 19 | fcMP4Config m_conf; 20 | std::mutex m_mutex; 21 | RawVector m_video_frame_info; 22 | RawVector m_audio_frame_info; 23 | RawVector m_pps; 24 | RawVector m_sps; 25 | RawVector m_iframe_ids; 26 | RawVector m_audio_encoder_info; 27 | 28 | size_t m_mdat_begin = 0; 29 | size_t m_mdat_end = 0; 30 | }; 31 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcMP4_Linux.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | 4 | #ifdef __linux__ 5 | 6 | fcIMP4Context* fcMP4OSCreateContextImpl(fcMP4Config &conf, fcIGraphicsDevice *dev, const char *path) 7 | { 8 | return nullptr; 9 | } 10 | 11 | bool fcMP4OSIsSupportedImpl() 12 | { 13 | return false; 14 | } 15 | 16 | #endif // __linux__ 17 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/MP4/fcMP4_Mac.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | 4 | #ifdef __APPLE__ 5 | // todo: use AVFoundation 6 | 7 | fcIMP4Context* fcMP4OSCreateContextImpl(fcMP4Config &conf, fcIGraphicsDevice *dev, const char *path) 8 | { 9 | return nullptr; 10 | } 11 | 12 | bool fcMP4OSIsSupportedImpl() 13 | { 14 | return false; 15 | } 16 | 17 | #endif // __APPLE__ 18 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/WebM/fcVPXEncoder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct fcVPXEncoderConfig 4 | { 5 | int width; 6 | int height; 7 | int target_framerate; 8 | fcBitrateMode bitrate_mode; 9 | int target_bitrate; 10 | }; 11 | 12 | 13 | fcIWebMVideoEncoder* fcCreateVPXVP8Encoder(const fcVPXEncoderConfig& conf); 14 | fcIWebMVideoEncoder* fcCreateVPXVP9Encoder(const fcVPXEncoderConfig& conf); 15 | fcIWebMVideoEncoder* fcCreateVPXVP9LossLessEncoder(const fcVPXEncoderConfig& conf); 16 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/WebM/fcVorbisEncoder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | struct fcVorbisEncoderConfig 5 | { 6 | int sample_rate; 7 | int num_channels; 8 | fcBitrateMode bitrate_mode; 9 | int target_bitrate; 10 | }; 11 | using fcOpusEncoderConfig = fcVorbisEncoderConfig; 12 | 13 | fcIWebMAudioEncoder* fcCreateVorbisEncoder(const fcVorbisEncoderConfig& conf); 14 | fcIWebMAudioEncoder* fcCreateOpusEncoder(const fcOpusEncoderConfig& conf); 15 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/WebM/fcWebMContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class fcIWebMContext : public fcContextBase 4 | { 5 | public: 6 | virtual void addOutputStream(fcStream *s) = 0; 7 | 8 | // timestamp=-1 is treated as current time. 9 | virtual bool addVideoFrameTexture(void *tex, fcPixelFormat fmt, fcTime timestamp = -1.0) = 0; 10 | 11 | // timestamp=-1 is treated as current time. 12 | virtual bool addVideoFramePixels(const void *pixels, fcPixelFormat fmt, fcTime timestamp = -1.0) = 0; 13 | 14 | virtual bool addAudioSamples(const float *samples, int num_samples) = 0; 15 | }; 16 | 17 | fcIWebMContext* fcWebMCreateContextImpl(fcWebMConfig &conf, fcIGraphicsDevice*); 18 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/WebM/fcWebMInternal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fcInternal.h" 4 | 5 | #ifdef fcSupportWebM 6 | #include "Foundation/fcFoundation.h" 7 | #include "GraphicsDevice/fcGraphicsDevice.h" 8 | 9 | 10 | struct fcWebMPacketInfo 11 | { 12 | uint32_t size; 13 | double timestamp; 14 | uint32_t keyframe : 1; 15 | }; 16 | 17 | struct fcWebMFrameData 18 | { 19 | using Packets = RawVector; 20 | Buffer data; 21 | Packets packets; 22 | 23 | void clear() 24 | { 25 | data.clear(); 26 | packets.clear(); 27 | } 28 | 29 | // Body: [](const char *data, const fcWebMPacketInfo& pinfo) {} 30 | template 31 | void eachPackets(const Body& body) const 32 | { 33 | int pos = 0; 34 | for (auto& p : packets) { 35 | body(&data[pos], p); 36 | pos += p.size; 37 | } 38 | } 39 | }; 40 | 41 | 42 | class fcIWebMEncoderInfo 43 | { 44 | public: 45 | virtual ~fcIWebMEncoderInfo() {} 46 | virtual const char* getMatroskaCodecID() const = 0; 47 | virtual const Buffer& getCodecPrivate() const = 0; 48 | }; 49 | 50 | class fcIWebMVideoEncoder : public fcIWebMEncoderInfo 51 | { 52 | public: 53 | virtual ~fcIWebMVideoEncoder() {} 54 | virtual bool encode(fcWebMFrameData& dst, const void *image, fcPixelFormat fmt, fcTime timestamp, bool force_keyframe = false) = 0; 55 | virtual bool flush(fcWebMFrameData& dst) = 0; 56 | }; 57 | 58 | class fcIWebMAudioEncoder : public fcIWebMEncoderInfo 59 | { 60 | public: 61 | virtual ~fcIWebMAudioEncoder() {} 62 | virtual bool encode(fcWebMFrameData& dst, const float *samples, size_t num_samples) = 0; 63 | virtual bool flush(fcWebMFrameData& dst) = 0; 64 | }; 65 | 66 | #endif // fcSupportWebM 67 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/WebM/fcWebMWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | 4 | #ifdef fcSupportWebM 5 | #include "fcWebMInternal.h" 6 | #include "fcWebMWriter.h" 7 | 8 | #ifdef _MSC_VER 9 | #pragma comment(lib, "libwebm.lib") 10 | #endif // _MSC_VER 11 | 12 | 13 | class fcMkvStream : public mkvmuxer::IMkvWriter 14 | { 15 | public: 16 | fcMkvStream(BinaryStream *stream) : m_stream(stream) { m_stream->addRef(); } 17 | ~fcMkvStream() { m_stream->release(); } 18 | int32_t Write(const void* buf, uint32_t len) override { m_stream->write(buf, len); return 0; } 19 | mkvmuxer::int64 Position() const override { return m_stream->tellp(); } 20 | mkvmuxer::int32 Position(mkvmuxer::int64 position) override { m_stream->seekp((size_t)position); return 0; } 21 | bool Seekable() const override { return true; } 22 | void ElementStartNotify(mkvmuxer::uint64 element_id, mkvmuxer::int64 position) override {} 23 | private: 24 | BinaryStream *m_stream = nullptr; 25 | }; 26 | 27 | 28 | fcWebMWriter::fcWebMWriter( 29 | BinaryStream *stream, const fcWebMConfig &conf, 30 | const fcIWebMVideoEncoder *vinfo, const fcIWebMAudioEncoder *ainfo) 31 | : m_stream(new fcMkvStream(stream)) 32 | { 33 | m_segment.Init(m_stream.get()); 34 | m_segment.set_mode(mkvmuxer::Segment::kFile); 35 | m_segment.set_estimate_file_duration(true); 36 | 37 | if (conf.video && vinfo) { 38 | m_video_track_id = m_segment.AddVideoTrack(conf.video_width, conf.video_height, VideoTrackIndex); 39 | auto track = dynamic_cast(m_segment.GetTrackByNumber(m_video_track_id)); 40 | track->set_codec_id(vinfo->getMatroskaCodecID()); 41 | track->set_display_width(conf.video_width); 42 | track->set_display_height(conf.video_height); 43 | track->set_frame_rate(conf.video_target_framerate); 44 | 45 | m_segment.CuesTrack(m_video_track_id); 46 | } 47 | 48 | if (conf.audio && ainfo) { 49 | m_audio_track_id = m_segment.AddAudioTrack(conf.audio_sample_rate, conf.audio_num_channels, AudioTrackIndex); 50 | auto track = dynamic_cast(m_segment.GetTrackByNumber(m_audio_track_id)); 51 | track->set_codec_id(ainfo->getMatroskaCodecID()); 52 | 53 | const auto& cp = ainfo->getCodecPrivate(); 54 | if (!cp.empty()) { 55 | track->SetCodecPrivate((const uint8_t*)cp.data(), cp.size()); 56 | } 57 | 58 | if (!conf.video) { 59 | m_segment.CuesTrack(m_audio_track_id); 60 | } 61 | } 62 | 63 | auto info = m_segment.GetSegmentInfo(); 64 | info->set_writing_app("Unity Movie Recorder"); 65 | } 66 | 67 | fcWebMWriter::~fcWebMWriter() 68 | { 69 | m_segment.Finalize(); 70 | } 71 | 72 | void fcWebMWriter::addFrame(mkvmuxer::Frame& f) 73 | { 74 | m_segment.AddGenericFrame(&f); 75 | } 76 | 77 | 78 | #endif // fcSupportWebM 79 | -------------------------------------------------------------------------------- /Plugin/fccore/Encoder/WebM/fcWebMWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mkvmuxer.hpp" 4 | 5 | class fcMkvStream; 6 | 7 | class fcWebMWriter 8 | { 9 | public: 10 | static const int VideoTrackIndex = 1; 11 | static const int AudioTrackIndex = 2; 12 | 13 | fcWebMWriter(BinaryStream *stream, const fcWebMConfig &conf, const fcIWebMVideoEncoder *vinfo, const fcIWebMAudioEncoder *ainfo); 14 | ~fcWebMWriter(); 15 | void addFrame(mkvmuxer::Frame& f); 16 | 17 | private: 18 | std::unique_ptr m_stream; 19 | mkvmuxer::Segment m_segment; 20 | uint64_t m_video_track_id = 0; 21 | uint64_t m_audio_track_id = 0; 22 | }; 23 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/Buffer.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | #include "Buffer.h" 4 | 5 | fcAPI void* AlignedAlloc(size_t size, size_t alignment) 6 | { 7 | size_t mask = alignment - 1; 8 | size = (size + mask) & (~mask); 9 | #ifdef _WIN32 10 | return _mm_malloc(size, alignment); 11 | #else 12 | void *ret = nullptr; 13 | posix_memalign(&ret, alignment, size); 14 | return ret; 15 | #endif 16 | } 17 | 18 | fcAPI void AlignedFree(void *addr) 19 | { 20 | #ifdef _WIN32 21 | _mm_free(addr); 22 | #else 23 | free(addr); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/Compression.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | #include "Misc.h" 4 | 5 | #ifdef fcSupportCompression 6 | #ifdef fcWindows 7 | #define ZIP_STATIC 8 | #pragma comment(lib, "libbz2.lib") 9 | #pragma comment(lib, "libzip.lib") 10 | #pragma comment(lib, "zlibstatic.lib") 11 | #endif 12 | #include 13 | #include 14 | 15 | 16 | bool BZ2Decompress(Buffer &dst, const void *src, size_t src_len) 17 | { 18 | const size_t initial_buffer_size = 1024 * 1024; 19 | if (dst.empty()) { dst.resize(initial_buffer_size); } 20 | 21 | int ret = 0; 22 | for (;;) { 23 | uint32_t dst_len = (uint32_t)dst.size(); 24 | BZ2_bzBuffToBuffDecompress(&dst[0], &dst_len, (char*)src, (uint32_t)src_len, 0, 0); 25 | if (ret == BZ_OUTBUFF_FULL) { 26 | dst.resize(dst.size() * 2); 27 | } 28 | else { 29 | dst.resize(dst_len); 30 | break; 31 | } 32 | } 33 | return ret == BZ_OK; 34 | } 35 | 36 | size_t BZ2DecompressToFile(const char *dst_path, const void *src, size_t src_len) 37 | { 38 | Buffer dst; 39 | if (!BZ2Decompress(dst, src, src_len)) { 40 | return 0; 41 | } 42 | 43 | FILE *fout = fopen(dst_path, "wb"); 44 | if (fout == nullptr) { return false; } 45 | fwrite(&dst[0], 1, dst.size(), fout); 46 | fclose(fout); 47 | return dst.size(); 48 | } 49 | 50 | 51 | size_t Unzip(const char *dst_path_, const char *archive, const UnzipFileHandler& handler) 52 | { 53 | struct zip *za; 54 | struct zip_file *zf; 55 | struct zip_stat sb; 56 | char buf[1024]; 57 | size_t ret = 0; 58 | std::string dst_path = dst_path_; 59 | 60 | int err; 61 | if ((za = zip_open(archive, 0, &err)) == nullptr) { 62 | zip_error_to_str(buf, sizeof(buf), err, errno); 63 | return false; 64 | } 65 | 66 | for (int i = 0; i < zip_get_num_entries(za, 0); ++i) { 67 | if (zip_stat_index(za, i, 0, &sb) == 0) { 68 | std::string dstpath = dst_path + '/' + sb.name; 69 | 70 | if (dstpath.back() == '/') { 71 | std::experimental::filesystem::create_directories(dstpath.c_str()); 72 | } 73 | else { 74 | zf = zip_fopen_index(za, i, 0); 75 | if (!zf) { 76 | goto bail_out; 77 | } 78 | 79 | FILE *of = fopen(dstpath.c_str(), "wb"); 80 | if (of == nullptr) { 81 | goto bail_out; 82 | } 83 | 84 | size_t sum = 0; 85 | while (sum != sb.size) { 86 | size_t len = (size_t)zip_fread(zf, buf, sizeof(buf)); 87 | if (len < 0) { 88 | fclose(of); 89 | goto bail_out; 90 | } 91 | fwrite(buf, 1, len, of); 92 | sum += len; 93 | } 94 | fclose(of); 95 | zip_fclose(zf); 96 | if (handler) { handler(dstpath.c_str()); } 97 | ++ret; 98 | } 99 | } 100 | } 101 | 102 | if (zip_close(za) == -1) { 103 | return false; 104 | } 105 | return ret; 106 | 107 | bail_out: 108 | zip_close(za); 109 | return ret; 110 | } 111 | #endif // fcSupportCompression 112 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/LazyInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | template 6 | class LazyInstance 7 | { 8 | public: 9 | T& get() 10 | { 11 | if (!m_instance) { 12 | m_instance.reset(new T()); 13 | } 14 | return *m_instance; 15 | } 16 | 17 | 18 | private: 19 | std::unique_ptr m_instance; 20 | }; 21 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/Misc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Buffer.h" 4 | 5 | #ifdef fcWindows 6 | #define fcDLLExt ".dll" 7 | #else 8 | #ifdef fcMac 9 | #define fcDLLExt ".dylib" 10 | #else 11 | #define fcDLLExt ".so" 12 | #endif 13 | #endif 14 | 15 | typedef void* module_t; 16 | module_t DLLLoad(const char *path); 17 | void DLLUnload(module_t mod); 18 | void* DLLGetSymbol(module_t mod, const char *name); 19 | void DLLAddSearchPath(const char *path); 20 | const char* DLLGetDirectoryOfCurrentModule(); 21 | 22 | double GetCurrentTimeInSeconds(); 23 | 24 | // execute command and **wait until it ends** 25 | // return exit-code 26 | int Execute(const char *command); 27 | 28 | void MilliSleep(int ms); 29 | 30 | 31 | // ------------------------------------------------------------- 32 | // Math functions 33 | // ------------------------------------------------------------- 34 | 35 | typedef uint8_t u8; 36 | typedef uint16_t u16; 37 | typedef uint32_t u32; 38 | typedef uint64_t u64; 39 | 40 | template 41 | inline u16 u16_be(Int v_) 42 | { 43 | u16 v = (u16)v_; 44 | return ((v >> 8) & 0xFF) | ((v & 0xFF) << 8); 45 | } 46 | 47 | template 48 | inline u32 u32_be(Int v_) 49 | { 50 | u32 v = (u32)v_; 51 | return ((v >> 24) & 0xFF) | (((v >> 16) & 0xFF) << 8) | (((v >> 8) & 0xFF) << 16) | ((v & 0xFF) << 24); 52 | } 53 | 54 | template 55 | inline u64 u64_be(Int v_) 56 | { 57 | u64 v = (u64)v_; 58 | return 59 | ((v >> 56) & 0xFF) | (((v >> 48) & 0xFF) << 8) | (((v >> 40) & 0xFF) << 16) | (((v >> 32) & 0xFF) << 24) | 60 | (((v >> 24) & 0xFF) << 32) | (((v >> 16) & 0xFF) << 40) | (((v >> 8) & 0xFF) << 48) | ((v & 0xFF) << 56); 61 | } 62 | 63 | // i.e: 64 | // ceildiv(31, 16) : 2 65 | // ceildiv(32, 16) : 2 66 | // ceildiv(33, 16) : 3 67 | template 68 | inline IntType ceildiv(IntType a, IntType b) 69 | { 70 | return (a + b - 1) / b; 71 | } 72 | 73 | // i.e: 74 | // roundup<16>(31) : 32 75 | // roundup<16>(32) : 32 76 | // roundup<16>(33) : 48 77 | template 78 | inline IntType roundup(IntType v) 79 | { 80 | IntType mask = N - 1; 81 | return (v + mask) & ~mask; 82 | } 83 | 84 | 85 | inline uint64_t to_msec(double seconds) { return uint64_t(seconds * 1000.0); } 86 | inline uint64_t to_usec(double seconds) { return uint64_t(seconds * 1000000.0); } 87 | inline uint64_t to_nsec(double seconds) { return uint64_t(seconds * 1000000000.0); } 88 | inline double msec_to_sec(uint64_t t) { return double(t) / 1000.0; } 89 | inline double usec_to_sec(uint64_t t) { return double(t) / 1000000.0; } 90 | inline double nsec_to_sec(uint64_t t) { return double(t) / 1000000000.0; } 91 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/Network.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | 4 | #ifdef fcSupportNetwork 5 | #ifdef fcWindows 6 | #define CURL_STATICLIB 7 | #endif 8 | #include 9 | #include "Misc.h" 10 | 11 | #ifdef fcWindows 12 | #pragma comment(lib, "libcurl.lib") 13 | #pragma comment(lib, "ws2_32.lib") 14 | #endif 15 | 16 | struct HTTPContext 17 | { 18 | const HTTPCallback& callback; 19 | int *status_code; 20 | }; 21 | 22 | static int HTTPCalback_Impl(char* data, size_t size, size_t nmemb, HTTPContext *ctx) 23 | { 24 | size_t len = size * nmemb; 25 | if (ctx->callback) { 26 | // abort if callback returned false 27 | if (!ctx->callback(data, len)) { 28 | return 0; 29 | } 30 | } 31 | return (int)len; 32 | } 33 | 34 | static bool HTTPGet_Impl(const std::string &url, HTTPContext &ctx) 35 | { 36 | CURL *curl = curl_easy_init(); 37 | if (curl == nullptr) { return false; } 38 | 39 | curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); 40 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &HTTPCalback_Impl); 41 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ctx); 42 | curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); 43 | 44 | bool ret = false; 45 | long http_code = 0; 46 | auto curl_code = curl_easy_perform(curl); 47 | if (curl_code == CURLE_OK) { 48 | curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code); 49 | ret = http_code == 200; 50 | } 51 | else { 52 | // curl_easy_strerror(curl_code); 53 | } 54 | curl_easy_cleanup(curl); 55 | 56 | if (ctx.status_code != nullptr) { 57 | *ctx.status_code = http_code; 58 | } 59 | return ret; 60 | } 61 | 62 | bool HTTPGet(const std::string &url, std::string &response, int *status_code) 63 | { 64 | HTTPCallback callback = [&](const char* data, size_t size) { 65 | response.append(data, size); 66 | return true; 67 | }; 68 | HTTPContext ctx = { callback, status_code }; 69 | return HTTPGet_Impl(url, ctx); 70 | } 71 | 72 | bool HTTPGet(const std::string &url, const HTTPCallback& callback, int *status_code) 73 | { 74 | HTTPContext ctx = { callback, status_code }; 75 | return HTTPGet_Impl(url, ctx); 76 | } 77 | #endif // fcSupportNetwork 78 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/PixelFormat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum fcPixelFormat; 4 | int fcGetPixelSize(fcPixelFormat format); 5 | 6 | void fcImageFlipY(void *image_, int width, int height, fcPixelFormat fmt); 7 | 8 | class half; 9 | void fcScaleArray(uint8_t *data, size_t size, float scale); 10 | void fcScaleArray(uint16_t *data, size_t size, float scale); 11 | void fcScaleArray(int32_t *data, size_t size, float scale); 12 | void fcScaleArray(half *data, size_t size, float scale); 13 | void fcScaleArray(float *data, size_t size, float scale); 14 | fcAPI const void* fcConvertPixelFormat(void *dst, fcPixelFormat dstfmt, const void *src, fcPixelFormat srcfmt, size_t size); 15 | 16 | // audio sample conversion 17 | void fcF32ToU8Samples(uint8_t *dst, const float *src, size_t size); 18 | void fcF32ToI16Samples(int16_t *dst, const float *src, size_t size); 19 | void fcF32ToI24Samples(uint8_t *dst, const float *src, size_t size); 20 | void fcF32ToI32Samples(int32_t *dst, const float *src, size_t size); 21 | void fcF32ToI32ScaleSamples(int32_t *dst, const float *src, size_t size, float scale); 22 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/TaskGroup.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | #include "TaskGroup.h" 4 | 5 | TaskGroup::TaskGroup() 6 | { 7 | } 8 | 9 | TaskGroup::~TaskGroup() 10 | { 11 | wait(); 12 | } 13 | 14 | void TaskGroup::wait() 15 | { 16 | for (auto& f : m_futures) { 17 | f.get(); 18 | } 19 | m_futures.clear(); 20 | } 21 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/TaskGroup.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | class TaskGroup 8 | { 9 | public: 10 | TaskGroup(); 11 | ~TaskGroup(); 12 | 13 | int getMaxTasks() const { return m_max_tasks; } 14 | void setMaxTasks(int v) { m_max_tasks = v; } 15 | 16 | void wait(); 17 | 18 | template 19 | void run(const Body &body) 20 | { 21 | while (m_futures.size() >= (size_t)m_max_tasks) { 22 | m_futures.front().get(); 23 | m_futures.pop_front(); 24 | } 25 | 26 | m_futures.push_back(std::async(std::launch::async, body)); 27 | } 28 | 29 | private: 30 | std::deque> m_futures; 31 | int m_max_tasks = 8; 32 | }; 33 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/TaskQueue.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "TaskQueue.h" 3 | 4 | //#define fcForceSingleThreaded 5 | 6 | TaskQueue::TaskQueue() 7 | { 8 | } 9 | 10 | TaskQueue::~TaskQueue() 11 | { 12 | wait(); 13 | } 14 | 15 | void TaskQueue::run(const Task& v) 16 | { 17 | #ifdef fcForceSingleThreaded 18 | v(); 19 | #else 20 | if (!m_running) { 21 | m_thread = std::thread([this]() { process(); }); 22 | m_running = true; 23 | } 24 | 25 | { 26 | Lock l(m_mutex); 27 | m_tasks.push_back(v); 28 | } 29 | m_condition.notify_one(); 30 | #endif 31 | } 32 | 33 | void TaskQueue::wait() 34 | { 35 | #ifdef fcForceSingleThreaded 36 | #else 37 | if (m_running) { 38 | m_stop = true; 39 | m_condition.notify_one(); 40 | m_thread.join(); 41 | m_running = false; 42 | m_stop = false; 43 | } 44 | #endif 45 | } 46 | 47 | bool TaskQueue::feed() 48 | { 49 | Task task; 50 | { 51 | Lock lock(m_mutex); 52 | if (!m_tasks.empty()) { 53 | task = m_tasks.front(); 54 | m_tasks.pop_front(); 55 | } 56 | } 57 | 58 | if (task) { 59 | task(); 60 | return true; 61 | } 62 | else { 63 | return false; 64 | } 65 | } 66 | 67 | void TaskQueue::process() 68 | { 69 | while (!m_stop || !m_tasks.empty()) 70 | { 71 | Task task; 72 | { 73 | Lock lock(m_mutex); 74 | while (!m_stop && m_tasks.empty()) { 75 | m_condition.wait(lock); 76 | } 77 | if (m_stop && m_tasks.empty()) { return; } 78 | 79 | task = m_tasks.front(); 80 | m_tasks.pop_front(); 81 | } 82 | task(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/TaskQueue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | template 15 | class SharedResources 16 | { 17 | public: 18 | using Resource = T; 19 | using ResourcePtr = std::shared_ptr; 20 | using ResourcePtrs = std::vector; 21 | using Lock = std::unique_lock; 22 | 23 | class ResourceHolder 24 | { 25 | public: 26 | ResourceHolder() {} 27 | ResourceHolder(SharedResources *owner, ResourcePtr res) 28 | : m_owner(owner), m_resource(res) 29 | {} 30 | ~ResourceHolder() 31 | { 32 | if (m_owner && m_resource) { 33 | if (m_resource.use_count() == 1) { 34 | m_owner->release(m_resource); 35 | } 36 | } 37 | } 38 | 39 | operator bool() const { return m_resource; } 40 | Resource& operator*() { return *m_resource; } 41 | const Resource& operator*() const { return *m_resource; } 42 | Resource* operator->() { return m_resource.get(); } 43 | const Resource* operator->() const { return m_resource.get(); } 44 | 45 | private: 46 | mutable SharedResources *m_owner = nullptr; 47 | ResourcePtr m_resource; 48 | }; 49 | 50 | template 51 | void emplace(Params&&... params) 52 | { 53 | add(new Resource(std::forward(params)...)); 54 | } 55 | 56 | void add(Resource *v) 57 | { 58 | Lock l(m_mutex); 59 | m_resources.emplace_back(v); 60 | m_max_resources = std::max(m_max_resources, m_resources.size()); 61 | } 62 | 63 | ResourceHolder acquire() 64 | { 65 | return acquire(std::chrono::hours(24)); 66 | } 67 | 68 | template 69 | ResourceHolder acquire(std::chrono::duration wait_time) 70 | { 71 | ResourceHolder ret; 72 | if (m_max_resources == 0) { return ret; } 73 | { 74 | Lock l(m_mutex); 75 | if (m_resources.empty()) { 76 | m_condition.wait_for(l, wait_time); 77 | } 78 | if (!m_resources.empty()) { 79 | ret = { this, m_resources.back() }; 80 | m_resources.pop_back(); 81 | } 82 | } 83 | return ret; 84 | } 85 | 86 | private: 87 | void release(ResourcePtr v) 88 | { 89 | { 90 | Lock l(m_mutex); 91 | m_resources.push_back(v); 92 | } 93 | m_condition.notify_one(); 94 | } 95 | 96 | private: 97 | std::mutex m_mutex; 98 | std::condition_variable m_condition; 99 | ResourcePtrs m_resources; 100 | size_t m_max_resources = 0; 101 | }; 102 | 103 | 104 | class TaskQueue 105 | { 106 | public: 107 | using Task = std::function; 108 | using Tasks = std::deque; 109 | using Lock = std::unique_lock; 110 | 111 | TaskQueue(); 112 | ~TaskQueue(); 113 | void wait(); 114 | bool feed(); 115 | void run(const Task& v); 116 | 117 | private: 118 | void process(); 119 | 120 | std::thread m_thread; 121 | std::mutex m_mutex; 122 | std::condition_variable m_condition; 123 | std::atomic_bool m_stop = { false }; 124 | std::atomic_bool m_running = { false }; 125 | Tasks m_tasks; 126 | }; 127 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/YUV.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | #include "YUV.h" 4 | #include "Misc.h" 5 | 6 | #include 7 | #ifdef _WIN32 8 | #pragma comment(lib, "yuv.lib") 9 | #endif 10 | 11 | 12 | // I420 13 | 14 | void I420Image::resize(int width, int height) 15 | { 16 | int s = roundup<2>(width) * roundup<2>(height); 17 | int sq = s / 4; 18 | m_buffer.resize(s + sq + sq); 19 | m_data.y = m_buffer.data(); 20 | m_data.u = (char*)m_data.y + s; 21 | m_data.v = (char*)m_data.u + sq; 22 | m_data.pitch_y = width; 23 | m_data.pitch_u = m_data.pitch_v = width / 4; 24 | m_data.height = height; 25 | } 26 | 27 | size_t I420Image::size() const 28 | { 29 | return m_buffer.size(); 30 | } 31 | I420Data& I420Image::data() 32 | { 33 | return m_data; 34 | } 35 | const I420Data& I420Image::data() const 36 | { 37 | return m_data; 38 | } 39 | 40 | void AnyToI420(I420Image& dst, Buffer& tmp, const void *pixels, fcPixelFormat fmt, int width, int height) 41 | { 42 | if (fmt != fcPixelFormat_RGBAu8 && fmt != fcPixelFormat_RGBu8) { 43 | tmp.resize(width * height * 4); 44 | fcConvertPixelFormat(tmp.data(), fcPixelFormat_RGBAu8, pixels, fmt, width * height); 45 | pixels = tmp.data(); 46 | fmt = fcPixelFormat_RGBAu8; 47 | } 48 | 49 | dst.resize(width, height); 50 | auto& data = dst.data(); 51 | if (fmt == fcPixelFormat_RGBAu8) { 52 | libyuv::ABGRToI420( 53 | (const uint8*)pixels, width * 4, 54 | (uint8*)data.y, width, 55 | (uint8*)data.u, width >> 1, 56 | (uint8*)data.v, width >> 1, 57 | width, height); 58 | } 59 | else if (fmt == fcPixelFormat_RGBu8) { 60 | libyuv::RAWToI420( 61 | (const uint8*)pixels, width * 3, 62 | (uint8*)data.y, width, 63 | (uint8*)data.u, width >> 1, 64 | (uint8*)data.v, width >> 1, 65 | width, height); 66 | } 67 | } 68 | 69 | 70 | 71 | // NV12 72 | 73 | void NV12Image::resize(int width, int height) 74 | { 75 | int s = roundup<2>(width) * roundup<2>(height); 76 | int sh = s / 2; 77 | m_buffer.resize(s + sh); 78 | m_data.y = m_buffer.data(); 79 | m_data.uv = (char*)m_data.y + s; 80 | m_data.pitch_y = width; 81 | m_data.pitch_uv = width / 2; 82 | m_data.height = height; 83 | } 84 | 85 | size_t NV12Image::size() const 86 | { 87 | return m_buffer.size(); 88 | } 89 | NV12Data& NV12Image::data() 90 | { 91 | return m_data; 92 | } 93 | const NV12Data& NV12Image::data() const 94 | { 95 | return m_data; 96 | } 97 | 98 | void AnyToNV12(NV12Image& dst, Buffer& tmp, const void *pixels, fcPixelFormat fmt, int width, int height) 99 | { 100 | if (fmt != fcPixelFormat_RGBAu8) { 101 | tmp.resize(width * height * 4); 102 | fcConvertPixelFormat(tmp.data(), fcPixelFormat_RGBAu8, pixels, fmt, width * height); 103 | pixels = tmp.data(); 104 | fmt = fcPixelFormat_RGBAu8; 105 | } 106 | 107 | dst.resize(width, height); 108 | auto& data = dst.data(); 109 | if (fmt == fcPixelFormat_RGBAu8) { 110 | libyuv::ARGBToNV12( 111 | (const uint8*)pixels, width * 4, 112 | (uint8*)data.y, width, 113 | (uint8*)data.uv, width, 114 | width, height); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/YUV.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Buffer.h" 4 | #include "PixelFormat.h" 5 | 6 | 7 | // I420 8 | 9 | struct I420Data 10 | { 11 | void *y = nullptr; 12 | void *u = nullptr; 13 | void *v = nullptr; 14 | int pitch_y = 0; 15 | int pitch_u = 0; 16 | int pitch_v = 0; 17 | int height = 0; 18 | }; 19 | 20 | class I420Image 21 | { 22 | public: 23 | void resize(int width, int height); 24 | size_t size() const; 25 | I420Data& data(); 26 | const I420Data& data() const; 27 | 28 | private: 29 | Buffer m_buffer; 30 | I420Data m_data; 31 | }; 32 | 33 | void AnyToI420(I420Image& dst, Buffer& tmp, const void *pixels, fcPixelFormat fmt, int width, int height); 34 | 35 | 36 | // NV12 37 | 38 | struct NV12Data 39 | { 40 | void *y = nullptr; 41 | void *uv = nullptr; 42 | int pitch_y = 0; 43 | int pitch_uv = 0; 44 | int height = 0; 45 | }; 46 | 47 | class NV12Image 48 | { 49 | public: 50 | void resize(int width, int height); 51 | size_t size() const; 52 | NV12Data& data(); 53 | const NV12Data& data() const; 54 | 55 | private: 56 | Buffer m_buffer; 57 | NV12Data m_data; 58 | }; 59 | 60 | void RGBAToNV12(NV12Image& dst, const void *rgba_pixels, int width, int height); 61 | void RGBAToNV12(const NV12Data& dst, const void *rgba_pixels, int width, int height); 62 | void AnyToNV12(NV12Image& dst, Buffer& tmp, const void *pixels, fcPixelFormat fmt, int width, int height); 63 | -------------------------------------------------------------------------------- /Plugin/fccore/Foundation/fcFoundation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../fccore.h" 4 | #include "Misc.h" 5 | #include "Buffer.h" 6 | #include "PixelFormat.h" 7 | #include "YUV.h" 8 | #include "LazyInstance.h" 9 | #include "TaskGroup.h" 10 | #include "TaskQueue.h" 11 | -------------------------------------------------------------------------------- /Plugin/fccore/GraphicsDevice/fcGraphicsDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class fcGfxDeviceType 4 | { 5 | Unknown, 6 | D3D9, 7 | D3D10, 8 | D3D11, 9 | D3D12, 10 | OpenGL, 11 | Vulkan, 12 | CUDA, 13 | }; 14 | 15 | 16 | class fcIGraphicsDevice 17 | { 18 | public: 19 | virtual ~fcIGraphicsDevice() {} 20 | virtual void* getDevicePtr() = 0; 21 | virtual fcGfxDeviceType getDeviceType() = 0; 22 | virtual void sync() = 0; 23 | virtual bool readTexture(void *o_buf, size_t bufsize, void *tex, int width, int height, fcPixelFormat format) = 0; 24 | virtual bool writeTexture(void *o_tex, int width, int height, fcPixelFormat format, const void *buf, size_t bufsize) = 0; 25 | }; 26 | fcAPI fcIGraphicsDevice* fcGetGraphicsDevice(); 27 | -------------------------------------------------------------------------------- /Plugin/fccore/fcInternal.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "fcInternal.h" 3 | #include "Foundation/fcFoundation.h" 4 | 5 | class fcAsyncDeleteManager 6 | { 7 | public: 8 | ~fcAsyncDeleteManager() 9 | { 10 | wait(); 11 | } 12 | 13 | void wait() 14 | { 15 | while (m_task_queue.feed()) {} 16 | m_task_queue.wait(); 17 | } 18 | 19 | void add(std::function v) 20 | { 21 | m_task_queue.run(v); 22 | } 23 | 24 | private: 25 | TaskQueue m_task_queue; 26 | }; 27 | 28 | static fcAsyncDeleteManager g_async_delete_manager; 29 | static bool g_async_delete = true; 30 | 31 | 32 | fcAPI void fcEnableAsyncReleaseContext(bool v) 33 | { 34 | g_async_delete = v; 35 | } 36 | 37 | fcAPI void fcWaitAsyncDelete() 38 | { 39 | g_async_delete_manager.wait(); 40 | } 41 | 42 | 43 | fcContextBase::~fcContextBase() 44 | { 45 | if (m_on_delete) { 46 | m_on_delete(); 47 | } 48 | } 49 | 50 | void fcContextBase::release() 51 | { 52 | if (g_async_delete) { g_async_delete_manager.add([this]() { delete this; }); } 53 | else { delete this; } 54 | } 55 | 56 | void fcContextBase::setOnDeleteCallback(std::function v) 57 | { 58 | m_on_delete = v; 59 | } 60 | -------------------------------------------------------------------------------- /Plugin/fccore/fcInternal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(_WIN32) 4 | #define fcWindows 5 | #elif defined(__APPLE__) 6 | #ifdef TARGET_OS_IPHONE 7 | #define fciOS 8 | #else 9 | #define fcMac 10 | #endif 11 | #elif defined(__ANDROID__) 12 | #define fcAndroid 13 | #elif defined(__linux__) 14 | #define fcLinux 15 | #endif 16 | 17 | 18 | #ifdef _WIN32 19 | #define fcSupportOpenGL 20 | #define fcSupportD3D9 21 | #define fcSupportD3D11 22 | 23 | #define fcSupportPNG 24 | #define fcSupportEXR 25 | #define fcSupportGIF 26 | #define fcSupportMP4 27 | #define fcSupportWebM 28 | 29 | //// MP4-related encoders 30 | #define fcSupportAAC_FAAC 31 | //#define fcSupportAAC_Intel 32 | #define fcSupportH264_OpenH264 33 | //#define fcSupportH264_NVIDIA 34 | //#define fcSupportH264_AMD 35 | //#define fcSupportH264_Intel 36 | 37 | //// WebM-related encoders 38 | #define fcSupportVPX 39 | #define fcSupportVorbis 40 | #define fcSupportOpus 41 | 42 | #define fcSupportWave 43 | #define fcSupportFlac 44 | #endif 45 | 46 | #define fcEnableLogging 47 | 48 | #ifdef fcEnableLogging 49 | void DebugLogImpl(const char* fmt, ...); 50 | #define fcDebugLog(...) DebugLogImpl(__VA_ARGS__) 51 | #else 52 | #define fcDebugLog(...) 53 | #endif 54 | 55 | 56 | class fcContextBase 57 | { 58 | protected: 59 | virtual ~fcContextBase(); 60 | public: 61 | virtual void release(); 62 | virtual void setOnDeleteCallback(std::function cb); 63 | 64 | private: 65 | std::function m_on_delete; 66 | }; 67 | 68 | #include "fccore.h" 69 | -------------------------------------------------------------------------------- /Plugin/fccore/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | -------------------------------------------------------------------------------- /Plugin/fccore/pch.h: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | #pragma warning(disable: 4190) 3 | #define _CRT_SECURE_NO_WARNINGS 4 | #endif 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #define fcImpl 25 | #include "fcInternal.h" 26 | -------------------------------------------------------------------------------- /Plugin/fccore_x86.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | UnityPluginLoad = _UnityPluginLoad@4 3 | UnityPluginUnload = _UnityPluginUnload@0 4 | -------------------------------------------------------------------------------- /Plugin/setup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | IF NOT EXIST "external\ispc.exe" ( 4 | IF NOT EXIST "external\external.7z" ( 5 | echo "downloading external libararies..." 6 | powershell.exe -Command "[System.Net.ServicePointManager]::SecurityProtocol=[System.Net.SecurityProtocolType]::Tls12; wget https://github.com/unity3d-jp/FrameCapturer/releases/download/20170510/external.7z -OutFile external/external.7z" 7 | ) 8 | cd external 9 | 7z\7za.exe x -aos external.7z 10 | cd .. 11 | ) 12 | -------------------------------------------------------------------------------- /Plugin/setup.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Master 14 | Win32 15 | 16 | 17 | Master 18 | x64 19 | 20 | 21 | 22 | 23 | Document 24 | %(Identity) 25 | %(Identity) 26 | External\ispc.exe 27 | External\ispc.exe 28 | %(Identity) 29 | false 30 | %(Identity) 31 | false 32 | External\ispc.exe 33 | External\ispc.exe 34 | %(Identity) 35 | %(Identity) 36 | %(Identity) 37 | %(Identity) 38 | false 39 | false 40 | 41 | 42 | 43 | {1C5DE91B-7AE9-4304-9FA1-0DE1ABA8C02D} 44 | MakeFileProj 45 | 10.0.14393.0 46 | 47 | 48 | 49 | Utility 50 | true 51 | v140 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | $(SolutionDir)_out\$(Platform)_$(Configuration)\ 60 | $(SolutionDir)_tmp\$(ProjectName)_$(Platform)_$(Configuration)\ 61 | 62 | 63 | $(SolutionDir)_out\$(Platform)_$(Configuration)\ 64 | $(SolutionDir)_tmp\$(ProjectName)_$(Platform)_$(Configuration)\ 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # FrameCapturer 3 | This plugin allow you to capture framebuffer, G-buffer and audio and output to file. Supported file formats are exr, png, gif, webm, mp4, wav, ogg and flac. You may also interested in [FrameRecorder](https://github.com/Unity-Technologies/GenericFrameRecorder). 4 | 5 | Supported platforms are Windows and Mac. (Also confirmed to work on Linux, but you need to build plugin from source) 6 | 7 | ## Usage 8 | 9 | 1. Import this package to your project: [FrameCapturer.unitypackage](https://github.com/unity3d-jp/FrameCapturer/releases/download/20170715/FrameCapturer.unitypackage) 10 | 2. Add recorder component to camera (Add Component -> UTJ -> FrameCapturer -> * Recorder) 11 | 3. Setup recorder settings and capture 12 | 13 | There are 3 recorder components: MovieRecorder, GBufferRecorder and AudioRecorder. 14 | - MovieRecorder: capture framebuffer and audio. 15 | - GBufferRecorder: capture G-buffer (depth buffer, albedo buffer, normal buffer, etc). This is useful for composite process in movie making. Rendering path must be deferred to use this recorder. 16 | - AudioRecorder: just capture audio. This is also useful for movie making. 17 | 18 | ## Limitations 19 | Currently MP4 recordering is available only on Windows. 20 | 21 | ## Example Outputs: 22 | ![gif_example1](Screenshots/gif_example1.gif) 23 | ![gif_example1](Screenshots/exr_example1.png) 24 | 25 | 26 | ## License 27 | [MIT](LICENSE.txt) 28 | -------------------------------------------------------------------------------- /Screenshots/ExrLayers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/ExrLayers.png -------------------------------------------------------------------------------- /Screenshots/ExrOffscreenRecorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/ExrOffscreenRecorder.png -------------------------------------------------------------------------------- /Screenshots/ExrRecorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/ExrRecorder.png -------------------------------------------------------------------------------- /Screenshots/GifOffscreenRecorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/GifOffscreenRecorder.png -------------------------------------------------------------------------------- /Screenshots/GifRecorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/GifRecorder.png -------------------------------------------------------------------------------- /Screenshots/MP4OffscreenRecorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/MP4OffscreenRecorder.png -------------------------------------------------------------------------------- /Screenshots/MP4Recorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/MP4Recorder.png -------------------------------------------------------------------------------- /Screenshots/PngOffscreenRecorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/PngOffscreenRecorder.png -------------------------------------------------------------------------------- /Screenshots/PngRecorder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/PngRecorder.png -------------------------------------------------------------------------------- /Screenshots/exr_example1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/exr_example1.png -------------------------------------------------------------------------------- /Screenshots/gif_capturer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/gif_capturer.gif -------------------------------------------------------------------------------- /Screenshots/gif_example1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unity3d-jp/FrameCapturer/5d3ba17e5ba12d62eaaa49c51f3336a4487fc8b2/Screenshots/gif_example1.gif --------------------------------------------------------------------------------