Compare commits
1 Commits
6866b7fca9
...
dev_video
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1db5db6a77 |
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2e9e076a217436a47b4b81811b4505db
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe: Hierarchy 右键菜单创建视频播放器
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public static class LeviathanVideoMenu
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 创建 UI 视频播放器 (RawImage)
|
||||||
|
/// </summary>
|
||||||
|
[MenuItem("GameObject/Leviathan Video/Leviathan Video Player (UI)", false, 10)]
|
||||||
|
private static void CreateUIVideoPlayer(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// 创建 GameObject
|
||||||
|
GameObject go = new GameObject("LeviathanVideoPlayer");
|
||||||
|
|
||||||
|
// 添加 RectTransform(UI 组件需要)
|
||||||
|
RectTransform rectTransform = go.AddComponent<RectTransform>();
|
||||||
|
rectTransform.sizeDelta = new Vector2(400, 300);
|
||||||
|
|
||||||
|
// 添加 RawImage 组件(LeviathanVideoDecoder 需要)
|
||||||
|
RawImage rawImage = go.AddComponent<RawImage>();
|
||||||
|
rawImage.color = Color.white;
|
||||||
|
|
||||||
|
// 添加视频解码器组件
|
||||||
|
go.AddComponent<LeviathanVideoDecoder>();
|
||||||
|
|
||||||
|
// 设置父物体
|
||||||
|
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
|
||||||
|
|
||||||
|
// 如果没有父物体,尝试放到 Canvas 下
|
||||||
|
if (go.transform.parent == null)
|
||||||
|
{
|
||||||
|
Canvas canvas = Object.FindObjectOfType<Canvas>();
|
||||||
|
if (canvas != null)
|
||||||
|
{
|
||||||
|
go.transform.SetParent(canvas.transform, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 如果没有 Canvas,创建一个
|
||||||
|
GameObject canvasGO = new GameObject("Canvas");
|
||||||
|
canvas = canvasGO.AddComponent<Canvas>();
|
||||||
|
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||||
|
canvasGO.AddComponent<CanvasScaler>();
|
||||||
|
canvasGO.AddComponent<GraphicRaycaster>();
|
||||||
|
go.transform.SetParent(canvas.transform, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册撤销
|
||||||
|
Undo.RegisterCreatedObjectUndo(go, "Create Leviathan Video Player (UI)");
|
||||||
|
|
||||||
|
// 选中创建的对象
|
||||||
|
Selection.activeObject = go;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建 3D 视频播放器 (Cube)
|
||||||
|
/// </summary>
|
||||||
|
[MenuItem("GameObject/Leviathan Video/Leviathan Video Player (3D Cube)", false, 11)]
|
||||||
|
private static void Create3DVideoPlayerCube(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// 创建 Cube
|
||||||
|
GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||||
|
go.name = "LeviathanVideoPlayer3D";
|
||||||
|
|
||||||
|
// 添加视频渲染器组件
|
||||||
|
go.AddComponent<LeviathanVideo3DRenderer>();
|
||||||
|
|
||||||
|
// 设置父物体
|
||||||
|
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
|
||||||
|
|
||||||
|
// 注册撤销
|
||||||
|
Undo.RegisterCreatedObjectUndo(go, "Create Leviathan Video Player (3D Cube)");
|
||||||
|
|
||||||
|
// 选中创建的对象
|
||||||
|
Selection.activeObject = go;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建 3D 视频播放器 (Quad/Plane)
|
||||||
|
/// </summary>
|
||||||
|
[MenuItem("GameObject/Leviathan Video/Leviathan Video Player (3D Quad)", false, 12)]
|
||||||
|
private static void Create3DVideoPlayerQuad(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// 创建 Quad
|
||||||
|
GameObject go = GameObject.CreatePrimitive(PrimitiveType.Quad);
|
||||||
|
go.name = "LeviathanVideoPlayer3D";
|
||||||
|
|
||||||
|
// 添加视频渲染器组件
|
||||||
|
go.AddComponent<LeviathanVideo3DRenderer>();
|
||||||
|
|
||||||
|
// 设置父物体
|
||||||
|
GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject);
|
||||||
|
|
||||||
|
// 注册撤销
|
||||||
|
Undo.RegisterCreatedObjectUndo(go, "Create Leviathan Video Player (3D Quad)");
|
||||||
|
|
||||||
|
// 选中创建的对象
|
||||||
|
Selection.activeObject = go;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d7270087496e8e04a9f7984720cd2362
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
#if UNITY_WEBGL
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.PackageManager;
|
||||||
|
using UnityEditor.PackageManager.Requests;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace LeviathanVideo.Editor
|
||||||
|
{
|
||||||
|
public static class WeChatMiniGameMenu
|
||||||
|
{
|
||||||
|
private const string SourcePath = "Assets/WX-WASM-SDK-V2-v0.1.32~";
|
||||||
|
private const string TargetPath = "Assets/WX-WASM-SDK-V2";
|
||||||
|
private const string LeviathanWasmPath = "Assets/WX-WASM-SDK-V2/Editor/template/minigame/leviathan.wasm.br";
|
||||||
|
private const string WeChatSDKGitUrl = "https://github.com/wechat-miniprogram/minigame-tuanjie-transform-sdk.git";
|
||||||
|
|
||||||
|
private static AddRequest _addRequest;
|
||||||
|
|
||||||
|
// 验证函数:只在 WX-WASM-SDK-V2 文件夹不存在时启用
|
||||||
|
[MenuItem("微信小游戏/[LeviathanVideo] 安装微信SDK", true)]
|
||||||
|
public static bool ValidateInstallWeChatSDK()
|
||||||
|
{
|
||||||
|
return !Directory.Exists(TargetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("微信小游戏/[LeviathanVideo] 安装微信SDK", false)]
|
||||||
|
public static void InstallWeChatSDK()
|
||||||
|
{
|
||||||
|
Debug.Log($"[LeviathanVideo] 开始安装微信SDK: {WeChatSDKGitUrl}");
|
||||||
|
_addRequest = Client.Add(WeChatSDKGitUrl);
|
||||||
|
EditorApplication.update += OnInstallProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnInstallProgress()
|
||||||
|
{
|
||||||
|
if (_addRequest == null || !_addRequest.IsCompleted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
EditorApplication.update -= OnInstallProgress;
|
||||||
|
|
||||||
|
if (_addRequest.Status == StatusCode.Success)
|
||||||
|
{
|
||||||
|
Debug.Log($"[LeviathanVideo] 微信SDK安装成功: {_addRequest.Result.packageId}");
|
||||||
|
EditorUtility.DisplayDialog("安装成功",
|
||||||
|
$"微信小游戏SDK安装成功!\n\n包ID: {_addRequest.Result.packageId}\n\n请执行下一步操作:\n微信小游戏 -> [LeviathanVideo] ****首次安装微信SDK后需要执行此操作****",
|
||||||
|
"确定");
|
||||||
|
}
|
||||||
|
else if (_addRequest.Status >= StatusCode.Failure)
|
||||||
|
{
|
||||||
|
Debug.LogError($"[LeviathanVideo] 微信SDK安装失败: {_addRequest.Error.message}");
|
||||||
|
EditorUtility.DisplayDialog("安装失败", $"微信小游戏SDK安装失败!\n\n错误: {_addRequest.Error.message}", "确定");
|
||||||
|
}
|
||||||
|
|
||||||
|
_addRequest = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证函数:只在 leviathan.wasm.br 文件不存在时启用
|
||||||
|
[MenuItem("微信小游戏/[LeviathanVideo] ****首次安装微信SDK后需要执行此操作**** ", true)]
|
||||||
|
public static bool ValidateCopyFiles()
|
||||||
|
{
|
||||||
|
// 需要 SDK 已安装 且 leviathan.wasm.br 文件不存在
|
||||||
|
return Directory.Exists(TargetPath) && !File.Exists(LeviathanWasmPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem("微信小游戏/[LeviathanVideo] ****首次安装微信SDK后需要执行此操作**** ", false)]
|
||||||
|
public static void CopyFiles()
|
||||||
|
{
|
||||||
|
string sourcePath = Path.GetFullPath(SourcePath);
|
||||||
|
string targetPath = Path.GetFullPath(TargetPath);
|
||||||
|
|
||||||
|
if (!Directory.Exists(sourcePath))
|
||||||
|
{
|
||||||
|
EditorUtility.DisplayDialog("错误", $"源路径不存在: {sourcePath}", "确定");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(targetPath))
|
||||||
|
{
|
||||||
|
EditorUtility.DisplayDialog("错误", $"目标路径不存在: {targetPath}", "确定");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
CopyDirectory(sourcePath, targetPath);
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
EditorUtility.DisplayDialog("完成", $"已将文件从\n{SourcePath}\n复制到\n{TargetPath}", "确定");
|
||||||
|
Debug.Log($"[Leviathan] 文件复制完成: {SourcePath} -> {TargetPath}");
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
EditorUtility.DisplayDialog("错误", $"复制文件时出错: {e.Message}", "确定");
|
||||||
|
Debug.LogError($"[Leviathan] 复制文件失败: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CopyDirectory(string sourceDir, string targetDir)
|
||||||
|
{
|
||||||
|
// 复制所有文件
|
||||||
|
foreach (string file in Directory.GetFiles(sourceDir))
|
||||||
|
{
|
||||||
|
string fileName = Path.GetFileName(file);
|
||||||
|
string destFile = Path.Combine(targetDir, fileName);
|
||||||
|
File.Copy(file, destFile, true);
|
||||||
|
Debug.Log($"[Leviathan] 复制文件: {fileName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 递归复制所有子目录
|
||||||
|
foreach (string dir in Directory.GetDirectories(sourceDir))
|
||||||
|
{
|
||||||
|
string dirName = Path.GetFileName(dir);
|
||||||
|
string destDir = Path.Combine(targetDir, dirName);
|
||||||
|
|
||||||
|
if (!Directory.Exists(destDir))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(destDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
CopyDirectory(dir, destDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 00d9ffb1d338f3a47a581531161a43da
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b7ba47a303ab5a54aa50ce9e0ef18967
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b493b78c71ed7fe49951c8084f0f8b2a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,629 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace LeviathanVideo.Abstractions
|
||||||
|
{
|
||||||
|
|
||||||
|
public unsafe struct AVRational2 : IFixedArray<AVRational>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 2;
|
||||||
|
public int Length => 2;
|
||||||
|
AVRational _0; AVRational _1;
|
||||||
|
|
||||||
|
public AVRational this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 2) throw new ArgumentOutOfRangeException(); fixed (AVRational* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 2) throw new ArgumentOutOfRangeException(); fixed (AVRational* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVRational[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVRational* p0 = &_0) { var a = new AVRational[2]; for (uint i = 0; i < 2; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVRational[] array)
|
||||||
|
{
|
||||||
|
fixed (AVRational* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 2) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVRational[](AVRational2 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct short2 : IFixedArray<short>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 2;
|
||||||
|
public int Length => 2;
|
||||||
|
fixed short _[2];
|
||||||
|
|
||||||
|
public short this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public short[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new short[2]; for (uint i = 0; i < 2; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(short[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 2) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator short[](short2 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct void_ptr2 : IFixedArray
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 2;
|
||||||
|
public int Length => 2;
|
||||||
|
void* _0; void* _1;
|
||||||
|
|
||||||
|
public void* this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 2) throw new ArgumentOutOfRangeException(); fixed (void** p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 2) throw new ArgumentOutOfRangeException(); fixed (void** p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public void*[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (void** p0 = &_0) { var a = new void*[2]; for (uint i = 0; i < 2; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(void*[] array)
|
||||||
|
{
|
||||||
|
fixed (void** p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 2) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator void*[](void_ptr2 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVHDRPlusColorTransformParams3 : IFixedArray<AVHDRPlusColorTransformParams>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 3;
|
||||||
|
public int Length => 3;
|
||||||
|
AVHDRPlusColorTransformParams _0; AVHDRPlusColorTransformParams _1; AVHDRPlusColorTransformParams _2;
|
||||||
|
|
||||||
|
public AVHDRPlusColorTransformParams this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (AVHDRPlusColorTransformParams* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (AVHDRPlusColorTransformParams* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVHDRPlusColorTransformParams[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVHDRPlusColorTransformParams* p0 = &_0) { var a = new AVHDRPlusColorTransformParams[3]; for (uint i = 0; i < 3; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVHDRPlusColorTransformParams[] array)
|
||||||
|
{
|
||||||
|
fixed (AVHDRPlusColorTransformParams* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 3) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVHDRPlusColorTransformParams[](AVHDRPlusColorTransformParams3 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVRational3 : IFixedArray<AVRational>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 3;
|
||||||
|
public int Length => 3;
|
||||||
|
AVRational _0; AVRational _1; AVRational _2;
|
||||||
|
|
||||||
|
public AVRational this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (AVRational* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (AVRational* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVRational[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVRational* p0 = &_0) { var a = new AVRational[3]; for (uint i = 0; i < 3; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVRational[] array)
|
||||||
|
{
|
||||||
|
fixed (AVRational* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 3) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVRational[](AVRational3 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVRational3x2 : IFixedArray<AVRational2>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 3;
|
||||||
|
public int Length => 3;
|
||||||
|
AVRational2 _0; AVRational2 _1; AVRational2 _2;
|
||||||
|
|
||||||
|
public AVRational2 this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (AVRational2* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (AVRational2* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVRational2[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVRational2* p0 = &_0) { var a = new AVRational2[3]; for (uint i = 0; i < 3; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVRational2[] array)
|
||||||
|
{
|
||||||
|
fixed (AVRational2* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 3) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVRational2[](AVRational3x2 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct byte_ptr3 : IFixedArray
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 3;
|
||||||
|
public int Length => 3;
|
||||||
|
byte* _0; byte* _1; byte* _2;
|
||||||
|
|
||||||
|
public byte* this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (byte** p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (byte** p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public byte*[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (byte** p0 = &_0) { var a = new byte*[3]; for (uint i = 0; i < 3; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(byte*[] array)
|
||||||
|
{
|
||||||
|
fixed (byte** p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 3) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator byte*[](byte_ptr3 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct int3 : IFixedArray<int>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 3;
|
||||||
|
public int Length => 3;
|
||||||
|
fixed int _[3];
|
||||||
|
|
||||||
|
public int this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public int[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new int[3]; for (uint i = 0; i < 3; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(int[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 3) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator int[](int3 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct short3x2 : IFixedArray<short2>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 3;
|
||||||
|
public int Length => 3;
|
||||||
|
short2 _0; short2 _1; short2 _2;
|
||||||
|
|
||||||
|
public short2 this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (short2* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 3) throw new ArgumentOutOfRangeException(); fixed (short2* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public short2[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (short2* p0 = &_0) { var a = new short2[3]; for (uint i = 0; i < 3; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(short2[] array)
|
||||||
|
{
|
||||||
|
fixed (short2* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 3) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator short2[](short3x2 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVComponentDescriptor4 : IFixedArray<AVComponentDescriptor>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 4;
|
||||||
|
public int Length => 4;
|
||||||
|
AVComponentDescriptor _0; AVComponentDescriptor _1; AVComponentDescriptor _2; AVComponentDescriptor _3;
|
||||||
|
|
||||||
|
public AVComponentDescriptor this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 4) throw new ArgumentOutOfRangeException(); fixed (AVComponentDescriptor* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 4) throw new ArgumentOutOfRangeException(); fixed (AVComponentDescriptor* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVComponentDescriptor[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVComponentDescriptor* p0 = &_0) { var a = new AVComponentDescriptor[4]; for (uint i = 0; i < 4; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVComponentDescriptor[] array)
|
||||||
|
{
|
||||||
|
fixed (AVComponentDescriptor* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 4) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVComponentDescriptor[](AVComponentDescriptor4 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct byte_ptr4 : IFixedArray
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 4;
|
||||||
|
public int Length => 4;
|
||||||
|
byte* _0; byte* _1; byte* _2; byte* _3;
|
||||||
|
|
||||||
|
public byte* this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 4) throw new ArgumentOutOfRangeException(); fixed (byte** p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 4) throw new ArgumentOutOfRangeException(); fixed (byte** p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public byte*[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (byte** p0 = &_0) { var a = new byte*[4]; for (uint i = 0; i < 4; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(byte*[] array)
|
||||||
|
{
|
||||||
|
fixed (byte** p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 4) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator byte*[](byte_ptr4 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct byte4 : IFixedArray<byte>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 4;
|
||||||
|
public int Length => 4;
|
||||||
|
fixed byte _[4];
|
||||||
|
|
||||||
|
public byte this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public byte[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new byte[4]; for (uint i = 0; i < 4; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(byte[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 4) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator byte[](byte4 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct int4 : IFixedArray<int>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 4;
|
||||||
|
public int Length => 4;
|
||||||
|
fixed int _[4];
|
||||||
|
|
||||||
|
public int this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public int[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new int[4]; for (uint i = 0; i < 4; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(int[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 4) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator int[](int4 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct long4 : IFixedArray<long>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 4;
|
||||||
|
public int Length => 4;
|
||||||
|
fixed long _[4];
|
||||||
|
|
||||||
|
public long this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public long[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new long[4]; for (uint i = 0; i < 4; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(long[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 4) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator long[](long4 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct uint4 : IFixedArray<uint>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 4;
|
||||||
|
public int Length => 4;
|
||||||
|
fixed uint _[4];
|
||||||
|
|
||||||
|
public uint this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public uint[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new uint[4]; for (uint i = 0; i < 4; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(uint[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 4) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator uint[](uint4 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct ulong4 : IFixedArray<ulong>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 4;
|
||||||
|
public int Length => 4;
|
||||||
|
fixed ulong _[4];
|
||||||
|
|
||||||
|
public ulong this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public ulong[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new ulong[4]; for (uint i = 0; i < 4; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(ulong[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 4) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator ulong[](ulong4 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct int7 : IFixedArray<int>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 7;
|
||||||
|
public int Length => 7;
|
||||||
|
fixed int _[7];
|
||||||
|
|
||||||
|
public int this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public int[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new int[7]; for (uint i = 0; i < 7; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(int[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 7) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator int[](int7 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVBufferRef_ptr8 : IFixedArray
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 8;
|
||||||
|
public int Length => 8;
|
||||||
|
AVBufferRef* _0; AVBufferRef* _1; AVBufferRef* _2; AVBufferRef* _3; AVBufferRef* _4; AVBufferRef* _5; AVBufferRef* _6; AVBufferRef* _7;
|
||||||
|
|
||||||
|
public AVBufferRef* this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 8) throw new ArgumentOutOfRangeException(); fixed (AVBufferRef** p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 8) throw new ArgumentOutOfRangeException(); fixed (AVBufferRef** p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVBufferRef*[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVBufferRef** p0 = &_0) { var a = new AVBufferRef*[8]; for (uint i = 0; i < 8; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVBufferRef*[] array)
|
||||||
|
{
|
||||||
|
fixed (AVBufferRef** p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 8) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVBufferRef*[](AVBufferRef_ptr8 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct byte_ptr8 : IFixedArray
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 8;
|
||||||
|
public int Length => 8;
|
||||||
|
byte* _0; byte* _1; byte* _2; byte* _3; byte* _4; byte* _5; byte* _6; byte* _7;
|
||||||
|
|
||||||
|
public byte* this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 8) throw new ArgumentOutOfRangeException(); fixed (byte** p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 8) throw new ArgumentOutOfRangeException(); fixed (byte** p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public byte*[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (byte** p0 = &_0) { var a = new byte*[8]; for (uint i = 0; i < 8; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(byte*[] array)
|
||||||
|
{
|
||||||
|
fixed (byte** p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 8) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator byte*[](byte_ptr8 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct byte8 : IFixedArray<byte>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 8;
|
||||||
|
public int Length => 8;
|
||||||
|
fixed byte _[8];
|
||||||
|
|
||||||
|
public byte this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public byte[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new byte[8]; for (uint i = 0; i < 8; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(byte[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 8) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator byte[](byte8 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct int8 : IFixedArray<int>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 8;
|
||||||
|
public int Length => 8;
|
||||||
|
fixed int _[8];
|
||||||
|
|
||||||
|
public int this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public int[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new int[8]; for (uint i = 0; i < 8; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(int[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 8) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator int[](int8 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct ulong8 : IFixedArray<ulong>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 8;
|
||||||
|
public int Length => 8;
|
||||||
|
fixed ulong _[8];
|
||||||
|
|
||||||
|
public ulong this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public ulong[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new ulong[8]; for (uint i = 0; i < 8; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(ulong[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 8) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator ulong[](ulong8 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct int9 : IFixedArray<int>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 9;
|
||||||
|
public int Length => 9;
|
||||||
|
fixed int _[9];
|
||||||
|
|
||||||
|
public int this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public int[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new int[9]; for (uint i = 0; i < 9; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(int[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 9) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator int[](int9 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVHDRPlusPercentile15 : IFixedArray<AVHDRPlusPercentile>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 15;
|
||||||
|
public int Length => 15;
|
||||||
|
AVHDRPlusPercentile _0; AVHDRPlusPercentile _1; AVHDRPlusPercentile _2; AVHDRPlusPercentile _3; AVHDRPlusPercentile _4; AVHDRPlusPercentile _5; AVHDRPlusPercentile _6; AVHDRPlusPercentile _7; AVHDRPlusPercentile _8; AVHDRPlusPercentile _9; AVHDRPlusPercentile _10; AVHDRPlusPercentile _11; AVHDRPlusPercentile _12; AVHDRPlusPercentile _13; AVHDRPlusPercentile _14;
|
||||||
|
|
||||||
|
public AVHDRPlusPercentile this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 15) throw new ArgumentOutOfRangeException(); fixed (AVHDRPlusPercentile* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 15) throw new ArgumentOutOfRangeException(); fixed (AVHDRPlusPercentile* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVHDRPlusPercentile[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVHDRPlusPercentile* p0 = &_0) { var a = new AVHDRPlusPercentile[15]; for (uint i = 0; i < 15; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVHDRPlusPercentile[] array)
|
||||||
|
{
|
||||||
|
fixed (AVHDRPlusPercentile* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 15) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVHDRPlusPercentile[](AVHDRPlusPercentile15 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVRational15 : IFixedArray<AVRational>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 15;
|
||||||
|
public int Length => 15;
|
||||||
|
AVRational _0; AVRational _1; AVRational _2; AVRational _3; AVRational _4; AVRational _5; AVRational _6; AVRational _7; AVRational _8; AVRational _9; AVRational _10; AVRational _11; AVRational _12; AVRational _13; AVRational _14;
|
||||||
|
|
||||||
|
public AVRational this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 15) throw new ArgumentOutOfRangeException(); fixed (AVRational* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 15) throw new ArgumentOutOfRangeException(); fixed (AVRational* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVRational[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVRational* p0 = &_0) { var a = new AVRational[15]; for (uint i = 0; i < 15; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVRational[] array)
|
||||||
|
{
|
||||||
|
fixed (AVRational* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 15) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVRational[](AVRational15 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct byte16 : IFixedArray<byte>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 16;
|
||||||
|
public int Length => 16;
|
||||||
|
fixed byte _[16];
|
||||||
|
|
||||||
|
public byte this[uint i]
|
||||||
|
{
|
||||||
|
get => _[i];
|
||||||
|
set => _[i] = value;
|
||||||
|
}
|
||||||
|
public byte[] ToArray()
|
||||||
|
{
|
||||||
|
var a = new byte[16]; for (uint i = 0; i < 16; i++) a[i] = _[i]; return a;
|
||||||
|
}
|
||||||
|
public void UpdateFrom(byte[] array)
|
||||||
|
{
|
||||||
|
uint i = 0; foreach (var value in array) { _[i++] = value; if (i >= 16) return; }
|
||||||
|
}
|
||||||
|
public static implicit operator byte[](byte16 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVRational25 : IFixedArray<AVRational>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 25;
|
||||||
|
public int Length => 25;
|
||||||
|
AVRational _0; AVRational _1; AVRational _2; AVRational _3; AVRational _4; AVRational _5; AVRational _6; AVRational _7; AVRational _8; AVRational _9; AVRational _10; AVRational _11; AVRational _12; AVRational _13; AVRational _14; AVRational _15; AVRational _16; AVRational _17; AVRational _18; AVRational _19; AVRational _20; AVRational _21; AVRational _22; AVRational _23; AVRational _24;
|
||||||
|
|
||||||
|
public AVRational this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 25) throw new ArgumentOutOfRangeException(); fixed (AVRational* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 25) throw new ArgumentOutOfRangeException(); fixed (AVRational* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVRational[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVRational* p0 = &_0) { var a = new AVRational[25]; for (uint i = 0; i < 25; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVRational[] array)
|
||||||
|
{
|
||||||
|
fixed (AVRational* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 25) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVRational[](AVRational25 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe struct AVRational25x25 : IFixedArray<AVRational25>
|
||||||
|
{
|
||||||
|
public static readonly int ArrayLength = 25;
|
||||||
|
public int Length => 25;
|
||||||
|
AVRational25 _0; AVRational25 _1; AVRational25 _2; AVRational25 _3; AVRational25 _4; AVRational25 _5; AVRational25 _6; AVRational25 _7; AVRational25 _8; AVRational25 _9; AVRational25 _10; AVRational25 _11; AVRational25 _12; AVRational25 _13; AVRational25 _14; AVRational25 _15; AVRational25 _16; AVRational25 _17; AVRational25 _18; AVRational25 _19; AVRational25 _20; AVRational25 _21; AVRational25 _22; AVRational25 _23; AVRational25 _24;
|
||||||
|
|
||||||
|
public AVRational25 this[uint i]
|
||||||
|
{
|
||||||
|
get { if (i >= 25) throw new ArgumentOutOfRangeException(); fixed (AVRational25* p0 = &_0) { return *(p0 + i); } }
|
||||||
|
set { if (i >= 25) throw new ArgumentOutOfRangeException(); fixed (AVRational25* p0 = &_0) { *(p0 + i) = value; } }
|
||||||
|
}
|
||||||
|
public AVRational25[] ToArray()
|
||||||
|
{
|
||||||
|
fixed (AVRational25* p0 = &_0) { var a = new AVRational25[25]; for (uint i = 0; i < 25; i++) a[i] = *(p0 + i); return a; }
|
||||||
|
}
|
||||||
|
public void UpdateFrom(AVRational25[] array)
|
||||||
|
{
|
||||||
|
fixed (AVRational25* p0 = &_0) { uint i = 0; foreach (var value in array) { *(p0 + i++) = value; if (i >= 25) return; } }
|
||||||
|
}
|
||||||
|
public static implicit operator AVRational25[](AVRational25x25 @struct) => @struct.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8672a701b738a1c409125f98c38b79d7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace LeviathanVideo.Abstractions
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ConstCharPtrMarshaler : ICustomMarshaler
|
||||||
|
{
|
||||||
|
private static readonly ConstCharPtrMarshaler Instance = new ConstCharPtrMarshaler();
|
||||||
|
public object MarshalNativeToManaged(IntPtr pNativeData) => Marshal.PtrToStringAnsi(pNativeData);
|
||||||
|
|
||||||
|
public IntPtr MarshalManagedToNative(object managedObj) => IntPtr.Zero;
|
||||||
|
|
||||||
|
public void CleanUpNativeData(IntPtr pNativeData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CleanUpManagedData(object managedObj)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetNativeDataSize() => IntPtr.Size;
|
||||||
|
|
||||||
|
public static ICustomMarshaler GetInstance(string cookie) => Instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a6182afb215f53b409c298aeb135d0a9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,460 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace LeviathanVideo.Abstractions
|
||||||
|
{
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int _query_func(AVFilterContext* @p0);
|
||||||
|
public unsafe struct _query_func_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator _query_func_func(_query_func func) => new _query_func_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void av_buffer_create_free(void* @opaque, byte* @data);
|
||||||
|
public unsafe struct av_buffer_create_free_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_buffer_create_free_func(av_buffer_create_free func) => new av_buffer_create_free_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate AVBufferRef* av_buffer_pool_init_alloc(ulong @size);
|
||||||
|
public unsafe struct av_buffer_pool_init_alloc_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_buffer_pool_init_alloc_func(av_buffer_pool_init_alloc func) => new av_buffer_pool_init_alloc_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate AVBufferRef* av_buffer_pool_init2_alloc(void* @opaque, ulong @size);
|
||||||
|
public unsafe struct av_buffer_pool_init2_alloc_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_buffer_pool_init2_alloc_func(av_buffer_pool_init2_alloc func) => new av_buffer_pool_init2_alloc_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void av_buffer_pool_init2_pool_free(void* @opaque);
|
||||||
|
public unsafe struct av_buffer_pool_init2_pool_free_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_buffer_pool_init2_pool_free_func(av_buffer_pool_init2_pool_free func) => new av_buffer_pool_init2_pool_free_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void av_log_set_callback_callback(void* @p0, int @p1,
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER
|
||||||
|
[MarshalAs(UnmanagedType.LPUTF8Str)]
|
||||||
|
#else
|
||||||
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]
|
||||||
|
#endif
|
||||||
|
string @p2, byte* @p3);
|
||||||
|
public unsafe struct av_log_set_callback_callback_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_log_set_callback_callback_func(av_log_set_callback_callback func) => new av_log_set_callback_callback_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int av_tree_enumerate_cmp(void* @opaque, void* @elem);
|
||||||
|
public unsafe struct av_tree_enumerate_cmp_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_tree_enumerate_cmp_func(av_tree_enumerate_cmp func) => new av_tree_enumerate_cmp_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int av_tree_enumerate_enu(void* @opaque, void* @elem);
|
||||||
|
public unsafe struct av_tree_enumerate_enu_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_tree_enumerate_enu_func(av_tree_enumerate_enu func) => new av_tree_enumerate_enu_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int av_tree_find_cmp(void* @key, void* @b);
|
||||||
|
public unsafe struct av_tree_find_cmp_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_tree_find_cmp_func(av_tree_find_cmp func) => new av_tree_find_cmp_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int av_tree_insert_cmp(void* @key, void* @b);
|
||||||
|
public unsafe struct av_tree_insert_cmp_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator av_tree_insert_cmp_func(av_tree_insert_cmp func) => new av_tree_insert_cmp_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate AVClass* AVClass_child_class_iterate(void** @iter);
|
||||||
|
public unsafe struct AVClass_child_class_iterate_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVClass_child_class_iterate_func(AVClass_child_class_iterate func) => new AVClass_child_class_iterate_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void* AVClass_child_next(void* @obj, void* @prev);
|
||||||
|
public unsafe struct AVClass_child_next_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVClass_child_next_func(AVClass_child_next func) => new AVClass_child_next_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate AVClassCategory AVClass_get_category(void* @ctx);
|
||||||
|
public unsafe struct AVClass_get_category_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVClass_get_category_func(AVClass_get_category func) => new AVClass_get_category_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate string AVClass_item_name(void* @ctx);
|
||||||
|
public unsafe struct AVClass_item_name_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVClass_item_name_func(AVClass_item_name func) => new AVClass_item_name_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVClass_query_ranges(AVOptionRanges** @p0, void* @obj,
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER
|
||||||
|
[MarshalAs(UnmanagedType.LPUTF8Str)]
|
||||||
|
#else
|
||||||
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]
|
||||||
|
#endif
|
||||||
|
string @key, int @flags);
|
||||||
|
public unsafe struct AVClass_query_ranges_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVClass_query_ranges_func(AVClass_query_ranges func) => new AVClass_query_ranges_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int avcodec_default_execute_func(AVCodecContext* @c2, void* @arg2);
|
||||||
|
public unsafe struct avcodec_default_execute_func_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator avcodec_default_execute_func_func(avcodec_default_execute_func func) => new avcodec_default_execute_func_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int avcodec_default_execute2_func(AVCodecContext* @c2, void* @arg2, int @p2, int @p3);
|
||||||
|
public unsafe struct avcodec_default_execute2_func_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator avcodec_default_execute2_func_func(avcodec_default_execute2_func func) => new avcodec_default_execute2_func_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void AVCodecContext_draw_horiz_band(AVCodecContext* @s, AVFrame* @src, ref int8 @offset, int @y, int @type, int @height);
|
||||||
|
public unsafe struct AVCodecContext_draw_horiz_band_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecContext_draw_horiz_band_func(AVCodecContext_draw_horiz_band func) => new AVCodecContext_draw_horiz_band_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVCodecContext_execute(AVCodecContext* @c, func_func @func, void* @arg2, int* @ret, int @count, int @size);
|
||||||
|
public unsafe struct AVCodecContext_execute_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecContext_execute_func(AVCodecContext_execute func) => new AVCodecContext_execute_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVCodecContext_execute2(AVCodecContext* @c, func_func @func, void* @arg2, int* @ret, int @count);
|
||||||
|
public unsafe struct AVCodecContext_execute2_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecContext_execute2_func(AVCodecContext_execute2 func) => new AVCodecContext_execute2_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVCodecContext_get_buffer2(AVCodecContext* @s, AVFrame* @frame, int @flags);
|
||||||
|
public unsafe struct AVCodecContext_get_buffer2_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecContext_get_buffer2_func(AVCodecContext_get_buffer2 func) => new AVCodecContext_get_buffer2_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVCodecContext_get_encode_buffer(AVCodecContext* @s, AVPacket* @pkt, int @flags);
|
||||||
|
public unsafe struct AVCodecContext_get_encode_buffer_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecContext_get_encode_buffer_func(AVCodecContext_get_encode_buffer func) => new AVCodecContext_get_encode_buffer_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate AVPixelFormat AVCodecContext_get_format(AVCodecContext* @s, AVPixelFormat* @fmt);
|
||||||
|
public unsafe struct AVCodecContext_get_format_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecContext_get_format_func(AVCodecContext_get_format func) => new AVCodecContext_get_format_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void AVCodecParser_parser_close(AVCodecParserContext* @s);
|
||||||
|
public unsafe struct AVCodecParser_parser_close_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecParser_parser_close_func(AVCodecParser_parser_close func) => new AVCodecParser_parser_close_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVCodecParser_parser_init(AVCodecParserContext* @s);
|
||||||
|
public unsafe struct AVCodecParser_parser_init_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecParser_parser_init_func(AVCodecParser_parser_init func) => new AVCodecParser_parser_init_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVCodecParser_parser_parse(AVCodecParserContext* @s, AVCodecContext* @avctx, byte** @poutbuf, int* @poutbuf_size, byte* @buf, int @buf_size);
|
||||||
|
public unsafe struct AVCodecParser_parser_parse_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecParser_parser_parse_func(AVCodecParser_parser_parse func) => new AVCodecParser_parser_parse_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVCodecParser_split(AVCodecContext* @avctx, byte* @buf, int @buf_size);
|
||||||
|
public unsafe struct AVCodecParser_split_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVCodecParser_split_func(AVCodecParser_split func) => new AVCodecParser_split_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void AVD3D11VADeviceContext_lock(void* @lock_ctx);
|
||||||
|
public unsafe struct AVD3D11VADeviceContext_lock_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVD3D11VADeviceContext_lock_func(AVD3D11VADeviceContext_lock func) => new AVD3D11VADeviceContext_lock_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void AVD3D11VADeviceContext_unlock(void* @lock_ctx);
|
||||||
|
public unsafe struct AVD3D11VADeviceContext_unlock_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVD3D11VADeviceContext_unlock_func(AVD3D11VADeviceContext_unlock func) => new AVD3D11VADeviceContext_unlock_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVFilter_activate(AVFilterContext* @ctx);
|
||||||
|
public unsafe struct AVFilter_activate_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFilter_activate_func(AVFilter_activate func) => new AVFilter_activate_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVFilter_init(AVFilterContext* @ctx);
|
||||||
|
public unsafe struct AVFilter_init_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFilter_init_func(AVFilter_init func) => new AVFilter_init_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVFilter_preinit(AVFilterContext* @ctx);
|
||||||
|
public unsafe struct AVFilter_preinit_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFilter_preinit_func(AVFilter_preinit func) => new AVFilter_preinit_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVFilter_process_command(AVFilterContext* @p0,
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER
|
||||||
|
[MarshalAs(UnmanagedType.LPUTF8Str)]
|
||||||
|
#else
|
||||||
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]
|
||||||
|
#endif
|
||||||
|
string @cmd,
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER
|
||||||
|
[MarshalAs(UnmanagedType.LPUTF8Str)]
|
||||||
|
#else
|
||||||
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]
|
||||||
|
#endif
|
||||||
|
string @arg, byte* @res, int @res_len, int @flags);
|
||||||
|
public unsafe struct AVFilter_process_command_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFilter_process_command_func(AVFilter_process_command func) => new AVFilter_process_command_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void AVFilter_uninit(AVFilterContext* @ctx);
|
||||||
|
public unsafe struct AVFilter_uninit_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFilter_uninit_func(AVFilter_uninit func) => new AVFilter_uninit_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVFilterGraph_execute(AVFilterContext* @ctx, func_func @func, void* @arg, int* @ret, int @nb_jobs);
|
||||||
|
public unsafe struct AVFilterGraph_execute_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFilterGraph_execute_func(AVFilterGraph_execute func) => new AVFilterGraph_execute_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVFormatContext_control_message_cb(AVFormatContext* @s, int @type, void* @data, ulong @data_size);
|
||||||
|
public unsafe struct AVFormatContext_control_message_cb_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFormatContext_control_message_cb_func(AVFormatContext_control_message_cb func) => new AVFormatContext_control_message_cb_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVFormatContext_io_close2(AVFormatContext* @s, AVIOContext* @pb);
|
||||||
|
public unsafe struct AVFormatContext_io_close2_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFormatContext_io_close2_func(AVFormatContext_io_close2 func) => new AVFormatContext_io_close2_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVFormatContext_io_open(AVFormatContext* @s, AVIOContext** @pb,
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER
|
||||||
|
[MarshalAs(UnmanagedType.LPUTF8Str)]
|
||||||
|
#else
|
||||||
|
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]
|
||||||
|
#endif
|
||||||
|
string @url, int @flags, AVDictionary** @options);
|
||||||
|
public unsafe struct AVFormatContext_io_open_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVFormatContext_io_open_func(AVFormatContext_io_open func) => new AVFormatContext_io_open_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void AVHWDeviceContext_free(AVHWDeviceContext* @ctx);
|
||||||
|
public unsafe struct AVHWDeviceContext_free_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVHWDeviceContext_free_func(AVHWDeviceContext_free func) => new AVHWDeviceContext_free_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate void AVHWFramesContext_free(AVHWFramesContext* @ctx);
|
||||||
|
public unsafe struct AVHWFramesContext_free_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVHWFramesContext_free_func(AVHWFramesContext_free func) => new AVHWFramesContext_free_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int avio_alloc_context_read_packet(void* @opaque, byte* @buf, int @buf_size);
|
||||||
|
public unsafe struct avio_alloc_context_read_packet_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator avio_alloc_context_read_packet_func(avio_alloc_context_read_packet func) => new avio_alloc_context_read_packet_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate long avio_alloc_context_seek(void* @opaque, long @offset, int @whence);
|
||||||
|
public unsafe struct avio_alloc_context_seek_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator avio_alloc_context_seek_func(avio_alloc_context_seek func) => new avio_alloc_context_seek_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int avio_alloc_context_write_packet(void* @opaque, byte* @buf, int @buf_size);
|
||||||
|
public unsafe struct avio_alloc_context_write_packet_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator avio_alloc_context_write_packet_func(avio_alloc_context_write_packet func) => new avio_alloc_context_write_packet_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVIOContext_read_packet(void* @opaque, byte* @buf, int @buf_size);
|
||||||
|
public unsafe struct AVIOContext_read_packet_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVIOContext_read_packet_func(AVIOContext_read_packet func) => new AVIOContext_read_packet_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVIOContext_read_pause(void* @opaque, int @pause);
|
||||||
|
public unsafe struct AVIOContext_read_pause_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVIOContext_read_pause_func(AVIOContext_read_pause func) => new AVIOContext_read_pause_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate long AVIOContext_read_seek(void* @opaque, int @stream_index, long @timestamp, int @flags);
|
||||||
|
public unsafe struct AVIOContext_read_seek_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVIOContext_read_seek_func(AVIOContext_read_seek func) => new AVIOContext_read_seek_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate long AVIOContext_seek(void* @opaque, long @offset, int @whence);
|
||||||
|
public unsafe struct AVIOContext_seek_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVIOContext_seek_func(AVIOContext_seek func) => new AVIOContext_seek_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate ulong AVIOContext_update_checksum(ulong @checksum, byte* @buf, uint @size);
|
||||||
|
public unsafe struct AVIOContext_update_checksum_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVIOContext_update_checksum_func(AVIOContext_update_checksum func) => new AVIOContext_update_checksum_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVIOContext_write_data_type(void* @opaque, byte* @buf, int @buf_size, AVIODataMarkerType @type, long @time);
|
||||||
|
public unsafe struct AVIOContext_write_data_type_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVIOContext_write_data_type_func(AVIOContext_write_data_type func) => new AVIOContext_write_data_type_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVIOContext_write_packet(void* @opaque, byte* @buf, int @buf_size);
|
||||||
|
public unsafe struct AVIOContext_write_packet_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVIOContext_write_packet_func(AVIOContext_write_packet func) => new AVIOContext_write_packet_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int AVIOInterruptCB_callback(void* @p0);
|
||||||
|
public unsafe struct AVIOInterruptCB_callback_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator AVIOInterruptCB_callback_func(AVIOInterruptCB_callback func) => new AVIOInterruptCB_callback_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
public unsafe delegate int func(AVFilterContext* @ctx, void* @arg, int @jobnr, int @nb_jobs);
|
||||||
|
public unsafe struct func_func
|
||||||
|
{
|
||||||
|
public IntPtr Pointer;
|
||||||
|
public static implicit operator func_func(func func) => new func_func { Pointer = func == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(func) };
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6494f6467575f8f4686755f1fb403a78
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c64159813b5056848bf146c573693369
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
namespace LeviathanVideo.Abstractions
|
||||||
|
{
|
||||||
|
public interface IFixedArray
|
||||||
|
{
|
||||||
|
int Length { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal interface IFixedArray<T> : IFixedArray
|
||||||
|
{
|
||||||
|
T this[uint index] { get; set; }
|
||||||
|
T[] ToArray();
|
||||||
|
void UpdateFrom(T[] array);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 831fd920f1934bd46a5a38037ddf74b5
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "Leviathan.Core",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": true,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f1d67e105160e074c99d37c9215900e1
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
using System;
|
||||||
|
using Unity.Collections.LowLevel.Unsafe;
|
||||||
|
|
||||||
|
namespace LeviathanVideo.Abstractions
|
||||||
|
{
|
||||||
|
|
||||||
|
public static partial class leviathan
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX || UNITY_IOS
|
||||||
|
public static readonly int EAGAIN = 35;
|
||||||
|
public static readonly int ENOMEM = 12;
|
||||||
|
public static readonly int EINVAL = 22;
|
||||||
|
#elif UNITY_WEBGL && !UNITY_EDITOR
|
||||||
|
public static readonly int EAGAIN = 6;
|
||||||
|
public static readonly int ENOMEM = 48;
|
||||||
|
public static readonly int EINVAL = 28;
|
||||||
|
#else
|
||||||
|
public static readonly int EAGAIN = 11;
|
||||||
|
public static readonly int ENOMEM = 12;
|
||||||
|
public static readonly int EINVAL = 22;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// public static readonly int EPIPE = 32;
|
||||||
|
|
||||||
|
public static ulong UINT64_C<T>(T a)
|
||||||
|
=> Convert.ToUInt64(a);
|
||||||
|
|
||||||
|
public static int AVERROR_Enum<T1>(T1 a) where T1 : struct, IConvertible => -UnsafeUtility.EnumToInt(a);
|
||||||
|
|
||||||
|
public static int AVERROR<T1>(T1 a)
|
||||||
|
=> -Convert.ToInt32(a);
|
||||||
|
|
||||||
|
public static int MKTAG<T1, T2, T3, T4>(T1 a, T2 b, T3 c, T4 d)
|
||||||
|
=> (int)(Convert.ToUInt32(a) | (Convert.ToUInt32(b) << 8) | (Convert.ToUInt32(c) << 16) |
|
||||||
|
(Convert.ToUInt32(d) << 24));
|
||||||
|
|
||||||
|
public static int FFERRTAG<T1, T2, T3, T4>(T1 a, T2 b, T3 c, T4 d)
|
||||||
|
=> -MKTAG(a, b, c, d);
|
||||||
|
|
||||||
|
public static int AV_VERSION_INT<T1, T2, T3>(T1 a, T2 b, T3 c) =>
|
||||||
|
(Convert.ToInt32(a) << 16) | (Convert.ToInt32(b) << 8) | Convert.ToInt32(c);
|
||||||
|
|
||||||
|
public static string AV_VERSION_DOT<T1, T2, T3>(T1 a, T2 b, T3 c)
|
||||||
|
=> $"{a}.{b}.{c}";
|
||||||
|
|
||||||
|
public static string AV_VERSION<T1, T2, T3>(T1 a, T2 b, T3 c)
|
||||||
|
=> AV_VERSION_DOT(a, b, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ebc87a006120f7d4e8ac1faf1284562e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ac98c4f0ef273194db7db58423be559f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 25e968c51067fb54a85f6052c03f6bcc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace LeviathanVideo.Abstractions
|
||||||
|
{
|
||||||
|
|
||||||
|
public class UTF8Marshaler : ICustomMarshaler
|
||||||
|
{
|
||||||
|
private static readonly UTF8Marshaler Instance = new UTF8Marshaler();
|
||||||
|
|
||||||
|
public virtual object MarshalNativeToManaged(IntPtr pNativeData) => FromNative(Encoding.UTF8, pNativeData);
|
||||||
|
|
||||||
|
public virtual IntPtr MarshalManagedToNative(object managedObj)
|
||||||
|
{
|
||||||
|
if (managedObj == null)
|
||||||
|
return IntPtr.Zero;
|
||||||
|
|
||||||
|
if (!(managedObj is string str))
|
||||||
|
throw new MarshalDirectiveException($"{GetType().Name} must be used on a string.");
|
||||||
|
|
||||||
|
return FromManaged(Encoding.UTF8, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void CleanUpNativeData(IntPtr pNativeData)
|
||||||
|
{
|
||||||
|
//Free anything allocated by MarshalManagedToNative
|
||||||
|
//This is called after the native function call completes
|
||||||
|
|
||||||
|
if (pNativeData != IntPtr.Zero)
|
||||||
|
Marshal.FreeHGlobal(pNativeData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CleanUpManagedData(object managedObj)
|
||||||
|
{
|
||||||
|
//Free anything allocated by MarshalNativeToManaged
|
||||||
|
//This is called after the native function call completes
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetNativeDataSize() => -1; // Not a value type
|
||||||
|
|
||||||
|
public static ICustomMarshaler GetInstance(string cookie) => Instance;
|
||||||
|
|
||||||
|
public static unsafe string FromNative(Encoding encoding, IntPtr pNativeData) => FromNative(encoding, (byte*)pNativeData);
|
||||||
|
|
||||||
|
public static unsafe string FromNative(Encoding encoding, byte* pNativeData)
|
||||||
|
{
|
||||||
|
if (pNativeData == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var start = pNativeData;
|
||||||
|
var walk = start;
|
||||||
|
|
||||||
|
// Find the end of the string
|
||||||
|
while (*walk != 0) walk++;
|
||||||
|
|
||||||
|
if (walk == start)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
return new string((sbyte*)pNativeData, 0, (int)(walk - start), encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static unsafe IntPtr FromManaged(Encoding encoding, string value)
|
||||||
|
{
|
||||||
|
if (encoding == null || value == null)
|
||||||
|
return IntPtr.Zero;
|
||||||
|
|
||||||
|
var length = encoding.GetByteCount(value);
|
||||||
|
var buffer = (byte*)Marshal.AllocHGlobal(length + 1).ToPointer();
|
||||||
|
|
||||||
|
if (length > 0)
|
||||||
|
{
|
||||||
|
fixed (char* pValue = value)
|
||||||
|
{
|
||||||
|
encoding.GetBytes(pValue, value.Length, buffer, length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[length] = 0;
|
||||||
|
|
||||||
|
return new IntPtr(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3d3fb0a766a91b74782afd15644bd45b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f5804ddd88f687945bf3886c41d4a565
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,402 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace LeviathanVideo.Abstractions
|
||||||
|
{
|
||||||
|
|
||||||
|
public static unsafe partial class leviathan
|
||||||
|
{
|
||||||
|
/// <summary>Clip a signed 64-bit integer value into the -2147483648,2147483647 range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static int av_clipl_int32_c(long @a)
|
||||||
|
{
|
||||||
|
if ((((ulong)a + (2147483648UL)) & ~(4294967295UL)) != 0)
|
||||||
|
return (int)((a >> 63) ^ 2147483647);
|
||||||
|
else
|
||||||
|
return (int)a;
|
||||||
|
}
|
||||||
|
// original body hash: hVbFRW9NmALaR5Wqm8W2hfXu9xV8Kg7CEndQKK0wY4I=
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>Convert an AVRational to a `double`.</summary>
|
||||||
|
/// <param name="a">AVRational to convert</param>
|
||||||
|
/// <returns>`a` in floating-point form</returns>
|
||||||
|
public static double av_q2d(AVRational @a)
|
||||||
|
{
|
||||||
|
return a.num / (double)a.den;
|
||||||
|
}
|
||||||
|
// original body hash: j4R2BS8nF6czcUDVk5kKi9nLEdlTI/NRDYtnc1KFeyE=
|
||||||
|
|
||||||
|
#region unuse code
|
||||||
|
/*
|
||||||
|
/// <summary>Compute ceil(log2(x)).</summary>
|
||||||
|
/// <param name="x">value used to compute ceil(log2(x))</param>
|
||||||
|
/// <returns>computed ceiling of log2(x)</returns>
|
||||||
|
public static int av_ceil_log2_c(int @x)
|
||||||
|
{
|
||||||
|
return av_log2((uint)(x - 1U) << 1);
|
||||||
|
}
|
||||||
|
// original body hash: Y9QGw919/NB5ltczSPmZu5WZt+BfR1GGQ58ULgOxiNo=
|
||||||
|
|
||||||
|
/// <summary>Clip a signed integer value into the amin-amax range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <param name="amin">minimum value of the clip range</param>
|
||||||
|
/// <param name="amax">maximum value of the clip range</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static int av_clip_c(int @a, int @amin, int @amax)
|
||||||
|
{
|
||||||
|
if (a < amin)
|
||||||
|
return amin;
|
||||||
|
else if (a > amax)
|
||||||
|
return amax;
|
||||||
|
else
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
// original body hash: FGSX8EvLhMgYqP9+0z1+Clej4HxjpENDPDX7uAYLx6k=
|
||||||
|
|
||||||
|
/// <summary>Clip a signed integer value into the -32768,32767 range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static short av_clip_int16_c(int @a)
|
||||||
|
{
|
||||||
|
if (((a + 32768U) & ~65535) != 0)
|
||||||
|
return (short)((a >> 31) ^ 32767);
|
||||||
|
else
|
||||||
|
return (short)a;
|
||||||
|
}
|
||||||
|
// original body hash: l7ot2X+8YIG7Ze9ecaMTap87pGl9Q5kffGq1e9dS9Es=
|
||||||
|
|
||||||
|
/// <summary>Clip a signed integer value into the -128,127 range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static sbyte av_clip_int8_c(int @a)
|
||||||
|
{
|
||||||
|
if (((a + 128U) & ~255) != 0)
|
||||||
|
return (sbyte)((a >> 31) ^ 127);
|
||||||
|
else
|
||||||
|
return (sbyte)a;
|
||||||
|
}
|
||||||
|
// original body hash: 959D6ojD8+Bo9o7pGvHcWTnCDg5Ax0o328RGYDIiUvo=
|
||||||
|
|
||||||
|
/// <summary>Clip a signed integer into the -(2^p),(2^p-1) range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <param name="p">bit position to clip at</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static int av_clip_intp2_c(int @a, int @p)
|
||||||
|
{
|
||||||
|
if ((((uint)a + (1U << p)) & ~((2U << p) - 1)) != 0)
|
||||||
|
return (a >> 31) ^ ((1 << p) - 1);
|
||||||
|
else
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
// original body hash: H4R9TdJsLPxie0kMNORwLhiEFWSn5cG8vNmgEcRcwaE=
|
||||||
|
|
||||||
|
/// <summary>Clip a signed integer value into the 0-65535 range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static ushort av_clip_uint16_c(int @a)
|
||||||
|
{
|
||||||
|
if ((a & (~65535)) != 0)
|
||||||
|
return (ushort)((~a) >> 31);
|
||||||
|
else
|
||||||
|
return (ushort)a;
|
||||||
|
}
|
||||||
|
// original body hash: nI5Vkw30nAjS2NmNSdCSnHeAUcY47XT0lnrnsUK/bJ4=
|
||||||
|
|
||||||
|
/// <summary>Clip a signed integer value into the 0-255 range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static byte av_clip_uint8_c(int @a)
|
||||||
|
{
|
||||||
|
if ((a & (~255)) != 0)
|
||||||
|
return (byte)((~a) >> 31);
|
||||||
|
else
|
||||||
|
return (byte)a;
|
||||||
|
}
|
||||||
|
// original body hash: 32OGGgXBFRL7EcU8DizK9KbIFfU356+5hgUEyAOjIUY=
|
||||||
|
|
||||||
|
/// <summary>Clip a signed integer to an unsigned power of two range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <param name="p">bit position to clip at</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static uint av_clip_uintp2_c(int @a, int @p)
|
||||||
|
{
|
||||||
|
if ((a & ~((1U << p) - 1)) != 0)
|
||||||
|
return (uint)(~a) >> 31 & ((1U << p) - 1);
|
||||||
|
else
|
||||||
|
return (uint)a;
|
||||||
|
}
|
||||||
|
// original body hash: e+b5mkBcLXfL9tlPoRVY9A8fy1jLPsqovjAobPBirRs=
|
||||||
|
|
||||||
|
/// <summary>Clip a signed 64bit integer value into the amin-amax range.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <param name="amin">minimum value of the clip range</param>
|
||||||
|
/// <param name="amax">maximum value of the clip range</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static long av_clip64_c(long @a, long @amin, long @amax)
|
||||||
|
{
|
||||||
|
if (a < amin)
|
||||||
|
return amin;
|
||||||
|
else if (a > amax)
|
||||||
|
return amax;
|
||||||
|
else
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
// original body hash: FGSX8EvLhMgYqP9+0z1+Clej4HxjpENDPDX7uAYLx6k=
|
||||||
|
|
||||||
|
/// <summary>Clip a double value into the amin-amax range. If a is nan or -inf amin will be returned. If a is +inf amax will be returned.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <param name="amin">minimum value of the clip range</param>
|
||||||
|
/// <param name="amax">maximum value of the clip range</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static double av_clipd_c(double @a, double @amin, double @amax)
|
||||||
|
{
|
||||||
|
return ((((a) > (amin) ? (a) : (amin))) > (amax) ? (amax) : (((a) > (amin) ? (a) : (amin))));
|
||||||
|
}
|
||||||
|
// original body hash: 3g76qefPWCYqXraY2vYdxoH58/EKn5EeR9v7cGEBM6Y=
|
||||||
|
|
||||||
|
/// <summary>Clip a float value into the amin-amax range. If a is nan or -inf amin will be returned. If a is +inf amax will be returned.</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <param name="amin">minimum value of the clip range</param>
|
||||||
|
/// <param name="amax">maximum value of the clip range</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static float av_clipf_c(float @a, float @amin, float @amax)
|
||||||
|
{
|
||||||
|
return ((((a) > (amin) ? (a) : (amin))) > (amax) ? (amax) : (((a) > (amin) ? (a) : (amin))));
|
||||||
|
}
|
||||||
|
// original body hash: 3g76qefPWCYqXraY2vYdxoH58/EKn5EeR9v7cGEBM6Y=
|
||||||
|
|
||||||
|
/// <summary>Compare two rationals.</summary>
|
||||||
|
/// <param name="a">First rational</param>
|
||||||
|
/// <param name="b">Second rational</param>
|
||||||
|
/// <returns>One of the following values: - 0 if `a == b` - 1 if `a > b` - -1 if `a < b` - `INT_MIN` if one of the values is of the form `0 / 0`</returns>
|
||||||
|
public static int av_cmp_q(AVRational @a, AVRational @b)
|
||||||
|
{
|
||||||
|
long tmp = a.num * (long)b.den - b.num * (long)a.den;
|
||||||
|
if (tmp != 0)
|
||||||
|
return (int)((tmp ^ a.den ^ b.den) >> 63) | 1;
|
||||||
|
else if (b.den != 0 && a.den != 0)
|
||||||
|
return 0;
|
||||||
|
else if (a.num != 0 && b.num != 0)
|
||||||
|
return (a.num >> 31) - (b.num >> 31);
|
||||||
|
else
|
||||||
|
return (-2147483647 - 1);
|
||||||
|
}
|
||||||
|
// original body hash: M+RGb5gXGdDjfY/gK5ZeCYeYrZAxjTXZA9+XVu0I66Q=
|
||||||
|
|
||||||
|
/// <summary>Reinterpret a double as a 64-bit integer.</summary>
|
||||||
|
public static ulong av_double2int(double @f)
|
||||||
|
{
|
||||||
|
return (ulong)@f;
|
||||||
|
}
|
||||||
|
// original body hash: 2HuHK8WLchm3u+cK6H4QWhflx2JqfewtaSpj2Cwfi8M=
|
||||||
|
|
||||||
|
/// <summary>Reinterpret a float as a 32-bit integer.</summary>
|
||||||
|
public static uint av_float2int(float @f)
|
||||||
|
{
|
||||||
|
return (uint)@f;
|
||||||
|
}
|
||||||
|
// original body hash: uBvsHd8EeFnxDvSdDE1+k5Um29kCuf0aEJhAvDy0wZk=
|
||||||
|
|
||||||
|
/// <summary>Wrapper around av_frame_side_data_get_c() to workaround the limitation that for any type T the conversion from T * const * to const T * const * is not performed automatically in C.</summary>
|
||||||
|
public static AVFrameSideData* av_frame_side_data_get(AVFrameSideData** @sd, int @nb_sd, AVFrameSideDataType @type)
|
||||||
|
{
|
||||||
|
return av_frame_side_data_get_c(sd, nb_sd, type);
|
||||||
|
}
|
||||||
|
// original body hash: nxiyu/BnkvF9Z/fWwpii6qfquOeLA/wdeiuxyQQxS4E=
|
||||||
|
|
||||||
|
/// <summary>Wrapper around av_image_copy() to workaround the limitation that the conversion from uint8_t * const * to const uint8_t * const * is not performed automatically in C.</summary>
|
||||||
|
public static void av_image_copy2(ref byte_ptr4 @dst_data, in int4 @dst_linesizes, ref byte_ptr4 @src_data, in int4 @src_linesizes, AVPixelFormat @pix_fmt, int @width, int @height)
|
||||||
|
{
|
||||||
|
av_image_copy(ref dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt, width, height);
|
||||||
|
}
|
||||||
|
// original body hash: RdaM2zKuF7t0cNJItdh1SZPg9WiOfPpTwty5cHDiZ2A=
|
||||||
|
|
||||||
|
/// <summary>Reinterpret a 64-bit integer as a double.</summary>
|
||||||
|
public static double av_int2double(ulong @i)
|
||||||
|
{
|
||||||
|
return (double)@i;
|
||||||
|
}
|
||||||
|
// original body hash: iFt3hVHTpF9jjqIGAAf/c7FrGfenOXGxdsyMjmrbwvw=
|
||||||
|
|
||||||
|
/// <summary>Reinterpret a 32-bit integer as a float.</summary>
|
||||||
|
public static float av_int2float(uint @i)
|
||||||
|
{
|
||||||
|
return (float)@i;
|
||||||
|
}
|
||||||
|
// original body hash: wLGFPpW+aIvxW79y6BVY1LKz/j7yc3BdiaJ7mD4oQmw=
|
||||||
|
|
||||||
|
/// <summary>Invert a rational.</summary>
|
||||||
|
/// <param name="q">value</param>
|
||||||
|
/// <returns>1 / q</returns>
|
||||||
|
public static AVRational av_inv_q(AVRational @q)
|
||||||
|
{
|
||||||
|
var r = new AVRational { @num = q.den, @den = q.num };
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
// original body hash: sXbO4D7vmayAx56EFqz9C0kakcSPSryJHdk0hr0MOFY=
|
||||||
|
|
||||||
|
/// <summary>Fill the provided buffer with a string containing an error string corresponding to the AVERROR code errnum.</summary>
|
||||||
|
/// <param name="errbuf">a buffer</param>
|
||||||
|
/// <param name="errbuf_size">size in bytes of errbuf</param>
|
||||||
|
/// <param name="errnum">error code to describe</param>
|
||||||
|
/// <returns>the buffer in input, filled with the error description</returns>
|
||||||
|
public static byte* av_make_error_string(byte* @errbuf, ulong @errbuf_size, int @errnum)
|
||||||
|
{
|
||||||
|
av_strerror(errnum, errbuf, errbuf_size);
|
||||||
|
return errbuf;
|
||||||
|
}
|
||||||
|
// original body hash: DRHQHyLQNo9pTxA+wRw4zVDrC7Md1u3JWawQX0BVkqE=
|
||||||
|
|
||||||
|
/// <summary>Create an AVRational.</summary>
|
||||||
|
public static AVRational av_make_q(int @num, int @den)
|
||||||
|
{
|
||||||
|
var r = new AVRational { @num = num, @den = den };
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
// original body hash: IAPYNNcg3GX0PGxINeLQhb41dH921lPVKcnqxCk7ERA=
|
||||||
|
|
||||||
|
[Obsolete()]
|
||||||
|
public static uint av_mod_uintp2_c(uint @a, uint @p)
|
||||||
|
{
|
||||||
|
return av_zero_extend_c(a, p);
|
||||||
|
}
|
||||||
|
// original body hash: MfDd5KRKGNiwvccdrrbME05wNKCRzGTF1T24OggAyp0=
|
||||||
|
|
||||||
|
public static int av_parity_c(uint @v)
|
||||||
|
{
|
||||||
|
return av_popcount_c(v) & 1;
|
||||||
|
}
|
||||||
|
// original body hash: Hsrq5CWkNvuNTnqES92ZJYVYpKXFwosrZNja/oaUd0s=
|
||||||
|
|
||||||
|
/// <summary>Count number of bits set to one in x</summary>
|
||||||
|
/// <param name="x">value to count bits of</param>
|
||||||
|
/// <returns>the number of bits set to one in x</returns>
|
||||||
|
public static int av_popcount_c(uint @x)
|
||||||
|
{
|
||||||
|
x -= (x >> 1) & 1431655765;
|
||||||
|
x = (x & 858993459) + ((x >> 2) & 858993459);
|
||||||
|
x = (x + (x >> 4)) & 252645135;
|
||||||
|
x += x >> 8;
|
||||||
|
return (int)((x + (x >> 16)) & 63);
|
||||||
|
}
|
||||||
|
// original body hash: 6EqV8Ll7t/MGINV9Nh3TSEbNyUYeskm7HucpU0SAkgg=
|
||||||
|
|
||||||
|
/// <summary>Count number of bits set to one in x</summary>
|
||||||
|
/// <param name="x">value to count bits of</param>
|
||||||
|
/// <returns>the number of bits set to one in x</returns>
|
||||||
|
public static int av_popcount64_c(ulong @x)
|
||||||
|
{
|
||||||
|
return av_popcount_c((uint)x) + av_popcount_c((uint)(x >> 32));
|
||||||
|
}
|
||||||
|
// original body hash: 4wjPAKU9R0yS6OI8Y9h3L6de+uXt/lBm+zX7t5Ch18k=
|
||||||
|
|
||||||
|
/// <summary>Add two signed 32-bit values with saturation.</summary>
|
||||||
|
/// <param name="a">one value</param>
|
||||||
|
/// <param name="b">another value</param>
|
||||||
|
/// <returns>sum with signed saturation</returns>
|
||||||
|
public static int av_sat_add32_c(int @a, int @b)
|
||||||
|
{
|
||||||
|
return av_clipl_int32_c((long)a + b);
|
||||||
|
}
|
||||||
|
// original body hash: GAAy4GsS2n+9kJ/8hzuONPUOGIsiOj7PvXnLHUVrimY=
|
||||||
|
|
||||||
|
/// <summary>Add two signed 64-bit values with saturation.</summary>
|
||||||
|
/// <param name="a">one value</param>
|
||||||
|
/// <param name="b">another value</param>
|
||||||
|
/// <returns>sum with signed saturation</returns>
|
||||||
|
public static long av_sat_add64_c(long @a, long @b)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return @a + @b;
|
||||||
|
}
|
||||||
|
catch (OverflowException)
|
||||||
|
{
|
||||||
|
return ((double)@a + (double)@b) > 0d ? long.MaxValue : long.MinValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// original body hash: qeup76rp1rjakhMYQJWWEYIkpgscUcDfzDIrjyqk5iM=
|
||||||
|
|
||||||
|
/// <summary>Add a doubled value to another value with saturation at both stages.</summary>
|
||||||
|
/// <param name="a">first value</param>
|
||||||
|
/// <param name="b">value doubled and added to a</param>
|
||||||
|
/// <returns>sum sat(a + sat(2*b)) with signed saturation</returns>
|
||||||
|
public static int av_sat_dadd32_c(int @a, int @b)
|
||||||
|
{
|
||||||
|
return av_sat_add32_c(a, av_sat_add32_c(b, b));
|
||||||
|
}
|
||||||
|
// original body hash: Kbha6XFULk7dxB6zc5WRwoPczQVN7HBcNs9Hjlj/Caw=
|
||||||
|
|
||||||
|
/// <summary>Subtract a doubled value from another value with saturation at both stages.</summary>
|
||||||
|
/// <param name="a">first value</param>
|
||||||
|
/// <param name="b">value doubled and subtracted from a</param>
|
||||||
|
/// <returns>difference sat(a - sat(2*b)) with signed saturation</returns>
|
||||||
|
public static int av_sat_dsub32_c(int @a, int @b)
|
||||||
|
{
|
||||||
|
return av_sat_sub32_c(a, av_sat_add32_c(b, b));
|
||||||
|
}
|
||||||
|
// original body hash: ypu4i+30n3CeMxdL8pq7XDYAFBi1N5d2mkIT6zQ1bO0=
|
||||||
|
|
||||||
|
/// <summary>Subtract two signed 32-bit values with saturation.</summary>
|
||||||
|
/// <param name="a">one value</param>
|
||||||
|
/// <param name="b">another value</param>
|
||||||
|
/// <returns>difference with signed saturation</returns>
|
||||||
|
public static int av_sat_sub32_c(int @a, int @b)
|
||||||
|
{
|
||||||
|
return av_clipl_int32_c((long)a - b);
|
||||||
|
}
|
||||||
|
// original body hash: /tgXI2zbIgliqOwZbpnq7jSiVj0N70RjBFsbkIkWhsM=
|
||||||
|
|
||||||
|
/// <summary>Subtract two signed 64-bit values with saturation.</summary>
|
||||||
|
/// <param name="a">one value</param>
|
||||||
|
/// <param name="b">another value</param>
|
||||||
|
/// <returns>difference with signed saturation</returns>
|
||||||
|
public static long av_sat_sub64_c(long @a, long @b)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return @a - @b;
|
||||||
|
}
|
||||||
|
catch (OverflowException)
|
||||||
|
{
|
||||||
|
return ((double)@a - (double)@b) > 0d ? long.MaxValue : long.MinValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// original body hash: 6YrSxDrYVG1ac1wlCiXKMhTwj7Kx6eym/YtspKusrGk=
|
||||||
|
|
||||||
|
/// <summary>Return x default pointer in case p is NULL.</summary>
|
||||||
|
public static void* av_x_if_null(void* @p, void* @x)
|
||||||
|
{
|
||||||
|
return (void*)(p != null ? p : x);
|
||||||
|
}
|
||||||
|
// original body hash: zOY924eIk3VeTSNb9XcE2Yw8aZ4/jlzQSfP06k5n0nU=
|
||||||
|
|
||||||
|
/// <summary>Clear high bits from an unsigned integer starting with specific bit position</summary>
|
||||||
|
/// <param name="a">value to clip</param>
|
||||||
|
/// <param name="p">bit position to clip at. Must be between 0 and 31.</param>
|
||||||
|
/// <returns>clipped value</returns>
|
||||||
|
public static uint av_zero_extend_c(uint @a, uint @p)
|
||||||
|
{
|
||||||
|
return a & ((1U << (int)p) - 1);
|
||||||
|
}
|
||||||
|
// original body hash: ncn4Okxr9Nas1g/qCfpRHKtywuNmJuf3UED+o3wjadc=
|
||||||
|
|
||||||
|
/// <summary>ftell() equivalent for AVIOContext.</summary>
|
||||||
|
/// <returns>position or AVERROR.</returns>
|
||||||
|
public static long avio_tell(AVIOContext* @s)
|
||||||
|
{
|
||||||
|
return avio_seek(s, 0, 1);
|
||||||
|
}
|
||||||
|
// original body hash: o18c3ypeh9EsmYaplTel2ssgM2PZKTTDfMjsqEopycw=
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c6aafe78d5c8f034e91415b317e7a463
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1156a8d8f5e1b0c4ab423518683a73c4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a9ba0e5ea12d414b922e04da0d8f224
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1798e75878e264647a9f38b7a694542c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f0472c50f0c01884c8341ae655a7a45f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d349bdd529bf1384581da0acce9d9cf3
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARM64
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: da40082fb7afc814a880157ff135c348
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARM64
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5a590fa83370f1b43aded6dd0418dfb8
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARM64
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5f2c55beab072af43adbb43c9090cb33
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,67 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c5e0a9f6ab078aa4b8d1cd2e0ed2e318
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,67 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 49e15e07e8602b941b3d18e5abffaa29
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,67 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 46b4457b8ae0fe541bec45c4933cd4a9
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4f0cc0aea8eaabd4fa01decdabdb378d
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6b623314619024a4f8397da099579e7b
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: X86
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b12057dc023f6204791722a99fe1e136
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: X86
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5c4eb621215eaac4493ccaf301c98092
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: X86
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 01fc22b120dc2154489b6763f8b67a14
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b2cd264a94ddf5543bbc08419f909738
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: X86_64
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7a6ace9d32e3e1c4da47afe4e70e6a51
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: X86_64
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2dde4bb3706cbae4cb9d27bb84c0bc2a
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 0
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: X86_64
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7abe18c33e45106409484ecf638961e7
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,81 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1321dae2bbb2203448be993b522bc5ca
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 1
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
Exclude iOS: 0
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARMv7
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AddToEmbeddedBinaries: false
|
||||||
|
CPU: ARM64
|
||||||
|
CompileFlags:
|
||||||
|
FrameworkDependencies:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,81 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2a8f0aa76f9a4ac4982a0b5bb54fb699
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 1
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
Exclude iOS: 0
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARMv7
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AddToEmbeddedBinaries: false
|
||||||
|
CPU: ARM64
|
||||||
|
CompileFlags:
|
||||||
|
FrameworkDependencies:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,81 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e1a867319cb2d1e45af6dd4d7af86f52
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 1
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 1
|
||||||
|
Exclude OSXUniversal: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 1
|
||||||
|
Exclude iOS: 0
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARMv7
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
AddToEmbeddedBinaries: false
|
||||||
|
CPU: ARM64
|
||||||
|
CompileFlags:
|
||||||
|
FrameworkDependencies:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 93270d16fc4e3a543b873d501f4b8298
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,82 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 94013bd364da14843a3c0450deba42de
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 1
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 1
|
||||||
|
Exclude Editor: 0
|
||||||
|
Exclude Linux64: 0
|
||||||
|
Exclude OSXUniversal: 0
|
||||||
|
Exclude WebGL: 1
|
||||||
|
Exclude Win: 1
|
||||||
|
Exclude Win64: 0
|
||||||
|
Exclude iOS: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARMv7
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: Windows
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AddToEmbeddedBinaries: false
|
||||||
|
CPU: AnyCPU
|
||||||
|
CompileFlags:
|
||||||
|
FrameworkDependencies:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,82 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9aa4aaf564c6f004fbd39c77d01b26df
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 1
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 1
|
||||||
|
Exclude Editor: 0
|
||||||
|
Exclude Linux64: 0
|
||||||
|
Exclude OSXUniversal: 0
|
||||||
|
Exclude WebGL: 1
|
||||||
|
Exclude Win: 0
|
||||||
|
Exclude Win64: 0
|
||||||
|
Exclude iOS: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARMv7
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: Windows
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AddToEmbeddedBinaries: false
|
||||||
|
CPU: AnyCPU
|
||||||
|
CompileFlags:
|
||||||
|
FrameworkDependencies:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,82 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 00de4b8f1465be04eb184dd902c12dcf
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 1
|
||||||
|
isOverridable: 0
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
- first:
|
||||||
|
: Any
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
Exclude Android: 1
|
||||||
|
Exclude Editor: 0
|
||||||
|
Exclude Linux64: 0
|
||||||
|
Exclude OSXUniversal: 0
|
||||||
|
Exclude WebGL: 1
|
||||||
|
Exclude Win: 0
|
||||||
|
Exclude Win64: 0
|
||||||
|
Exclude iOS: 1
|
||||||
|
- first:
|
||||||
|
Android: Android
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AndroidSharedLibraryType: Executable
|
||||||
|
CPU: ARMv7
|
||||||
|
- first:
|
||||||
|
Any:
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings: {}
|
||||||
|
- first:
|
||||||
|
Editor: Editor
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: Windows
|
||||||
|
- first:
|
||||||
|
Standalone: Linux64
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: OSXUniversal
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: None
|
||||||
|
- first:
|
||||||
|
Standalone: Win64
|
||||||
|
second:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
- first:
|
||||||
|
iPhone: iOS
|
||||||
|
second:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
AddToEmbeddedBinaries: false
|
||||||
|
CPU: AnyCPU
|
||||||
|
CompileFlags:
|
||||||
|
FrameworkDependencies:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7a84f8bfdcd4feb499f3fb62f7e4cdf8
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using LeviathanVideo.Abstractions;
|
||||||
|
using Unity.Collections;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Leviathan视频解码器接口
|
||||||
|
/// </summary>
|
||||||
|
internal unsafe interface ILeviathanDecoder : IDisposable
|
||||||
|
{
|
||||||
|
// 事件
|
||||||
|
event Action OnFirstFrameDecoded;
|
||||||
|
// 属性
|
||||||
|
long FrameCount { get; }
|
||||||
|
double FrameInterval { get; }
|
||||||
|
string CodecName { get; }
|
||||||
|
long Duration { get; }
|
||||||
|
long DecodedFrameIndex { get; }
|
||||||
|
AVFrame* VideoFrame { get; }
|
||||||
|
bool IsLooping { get; set; }
|
||||||
|
|
||||||
|
// 方法
|
||||||
|
int Init(NativeArray<byte> fileData, int beginFrameIndex = 1, bool syncDecodeFirstFrame = true, bool fastDecode = true);
|
||||||
|
int InternalPlay(int beginFrameIndex = 1, bool syncDecodeFirstFrame = true);
|
||||||
|
int DecodeNextFrame();
|
||||||
|
void InternalStop();
|
||||||
|
void Seek(double ms);
|
||||||
|
void SeekToFrame(long frame);
|
||||||
|
void Pause(bool pause);
|
||||||
|
ref long GetDecodedFrameIndexRef();
|
||||||
|
|
||||||
|
// 微信平台特有方法(其他平台提供空实现)
|
||||||
|
int GetDecoderStatus();
|
||||||
|
|
||||||
|
// 优化的分步显示方法
|
||||||
|
/// <summary>
|
||||||
|
/// 将视频帧数据复制到纹理(需要在信号保护下执行)
|
||||||
|
/// </summary>
|
||||||
|
void CopyFrameDataToTextures(UnityEngine.Texture2D[] textures);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将纹理数据应用到GPU(可以和下一帧解码并行)
|
||||||
|
/// </summary>
|
||||||
|
void ApplyTextures(UnityEngine.Texture2D[] textures);
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3aa07cec7daa4b94abd02bcd26cec3ca
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "Leviathan.Runtime",
|
||||||
|
"rootNamespace": "",
|
||||||
|
"references": [
|
||||||
|
"GUID:f1d67e105160e074c99d37c9215900e1"
|
||||||
|
],
|
||||||
|
"includePlatforms": [],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": true,
|
||||||
|
"overrideReferences": false,
|
||||||
|
"precompiledReferences": [],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cb496f7121888314e838e8d8fd3425e6
|
||||||
|
AssemblyDefinitionImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/10/29
|
||||||
|
// Module Describe: Leviathan日志配置类
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
//******************************************************************
|
||||||
|
// 日志配置类
|
||||||
|
//******************************************************************
|
||||||
|
public static class LeviathanLogConfig
|
||||||
|
{
|
||||||
|
// 日志开关
|
||||||
|
private static bool _enableWorkerManagerLog = false;
|
||||||
|
private static bool _enableWorkerVideoLog = false;
|
||||||
|
private static bool _enableWorkerDecoderLog = false;
|
||||||
|
private static bool _enableSoftwareDecoderLog = false;
|
||||||
|
private static bool _enableVideoDecoderLog = false;
|
||||||
|
private static bool _enableAllLog = false;
|
||||||
|
|
||||||
|
// 公开属性
|
||||||
|
public static bool EnableWorkerManagerLog
|
||||||
|
{
|
||||||
|
get => _enableWorkerManagerLog;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_enableWorkerManagerLog = value;
|
||||||
|
UpdateJSLogConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool EnableWorkerVideoLog
|
||||||
|
{
|
||||||
|
get => _enableWorkerVideoLog;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_enableWorkerVideoLog = value;
|
||||||
|
UpdateJSLogConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool EnableWorkerDecoderLog
|
||||||
|
{
|
||||||
|
get => _enableWorkerDecoderLog;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_enableWorkerDecoderLog = value;
|
||||||
|
UpdateJSLogConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool EnableSoftwareDecoderLog
|
||||||
|
{
|
||||||
|
get => _enableSoftwareDecoderLog;
|
||||||
|
set => _enableSoftwareDecoderLog = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool EnableVideoDecoderLog
|
||||||
|
{
|
||||||
|
get => _enableVideoDecoderLog;
|
||||||
|
set => _enableVideoDecoderLog = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool EnableAllLog
|
||||||
|
{
|
||||||
|
get => _enableAllLog;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_enableAllLog = value;
|
||||||
|
UpdateJSLogConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern void SetLeviathanLogConfig(bool workerManager, bool workerVideo, bool workerDecoder, bool all);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 更新JS端的日志配置
|
||||||
|
private static void UpdateJSLogConfig()
|
||||||
|
{
|
||||||
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SetLeviathanLogConfig(_enableWorkerManagerLog, _enableWorkerVideoLog, _enableWorkerDecoderLog, _enableAllLog);
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"[LeviathanLogConfig] 更新JS日志配置失败: {e.Message}");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// 便捷方法:开启所有日志
|
||||||
|
public static void EnableAll()
|
||||||
|
{
|
||||||
|
EnableAllLog = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 便捷方法:关闭所有日志
|
||||||
|
public static void DisableAll()
|
||||||
|
{
|
||||||
|
EnableAllLog = false;
|
||||||
|
EnableWorkerManagerLog = false;
|
||||||
|
EnableWorkerVideoLog = false;
|
||||||
|
EnableWorkerDecoderLog = false;
|
||||||
|
EnableSoftwareDecoderLog = false;
|
||||||
|
EnableVideoDecoderLog = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// C#端日志辅助方法
|
||||||
|
public static void Log(string module, object message)
|
||||||
|
{
|
||||||
|
if (!ShouldLog(module)) return;
|
||||||
|
Debug.Log($"[Leviathan{module}] {message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogWarning(string module, object message)
|
||||||
|
{
|
||||||
|
if (!ShouldLog(module)) return;
|
||||||
|
Debug.LogWarning($"[Leviathan{module}] {message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LogError(string module, object message)
|
||||||
|
{
|
||||||
|
if (!ShouldLog(module)) return;
|
||||||
|
Debug.LogError($"[Leviathan{module}] {message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool ShouldLog(string module)
|
||||||
|
{
|
||||||
|
if (_enableAllLog) return true;
|
||||||
|
|
||||||
|
return module switch
|
||||||
|
{
|
||||||
|
"WorkerManager" => _enableWorkerManagerLog,
|
||||||
|
"WorkerVideo" => _enableWorkerVideoLog,
|
||||||
|
"WorkerDecoder" => _enableWorkerDecoderLog,
|
||||||
|
"SoftwareDecoder" => _enableSoftwareDecoderLog,
|
||||||
|
"VideoDecoder" => _enableVideoDecoderLog,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 52a41d7bdc4a88241888a81be912b716
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,301 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe: 3D MeshRenderer 视频渲染组件
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 3D MeshRenderer 视频渲染组件
|
||||||
|
/// 继承自 LeviathanVideoDecoderBase,用于在 3D 物体(如 Cube、Plane)上显示视频
|
||||||
|
/// </summary>
|
||||||
|
[RequireComponent(typeof(MeshRenderer))]
|
||||||
|
public unsafe class LeviathanVideo3DRenderer : LeviathanVideoDecoderBase
|
||||||
|
{
|
||||||
|
private static readonly int MainTexIdx = Shader.PropertyToID("_MainTex");
|
||||||
|
|
||||||
|
[Header("3D Renderer Settings")]
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("是否翻转Y轴UV,用于修正不同模型的UV方向")]
|
||||||
|
private bool _reverseY = true;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("材质所在的索引(用于多材质渲染器)")]
|
||||||
|
private int _materialIndex = 0;
|
||||||
|
|
||||||
|
private Material _material;
|
||||||
|
|
||||||
|
private new static void Log(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.Log("Video3DRenderer", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private new static void LogWarning(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.LogWarning("Video3DRenderer", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private new static void LogError(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.LogError("Video3DRenderer", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用渲染目标
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnEnableRenderTarget()
|
||||||
|
{
|
||||||
|
MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
|
||||||
|
if (meshRenderer)
|
||||||
|
{
|
||||||
|
meshRenderer.enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 禁用渲染目标
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnDisableRenderTarget()
|
||||||
|
{
|
||||||
|
MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
|
||||||
|
if (meshRenderer)
|
||||||
|
{
|
||||||
|
meshRenderer.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新渲染目标尺寸
|
||||||
|
/// 3D渲染器不需要调整尺寸,由模型本身决定
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnUpdateRenderTargetSize()
|
||||||
|
{
|
||||||
|
// 3D渲染器不需要像UI那样自动调整尺寸
|
||||||
|
// 尺寸由模型本身决定
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化材质
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnInitMaterial()
|
||||||
|
{
|
||||||
|
MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
|
||||||
|
if (meshRenderer)
|
||||||
|
{
|
||||||
|
UpdateMeshMaterial(meshRenderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新材质
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnUpdateMaterial()
|
||||||
|
{
|
||||||
|
MeshRenderer meshRenderer = GetComponent<MeshRenderer>();
|
||||||
|
if (meshRenderer)
|
||||||
|
{
|
||||||
|
UpdateMeshMaterial(meshRenderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void UpdateMeshMaterial(MeshRenderer meshRenderer)
|
||||||
|
{
|
||||||
|
if (_textures == null || _textures.Length < 3) return;
|
||||||
|
|
||||||
|
// 创建新材质或更新现有材质
|
||||||
|
Material newMaterial;
|
||||||
|
switch (_alphaType)
|
||||||
|
{
|
||||||
|
case PlayAlphaType.RightSide:
|
||||||
|
newMaterial = new Material(Shader.Find("LeviathanVideo/YUV420P_3D_Alpha_Right"));
|
||||||
|
newMaterial.SetFloat(ValidWidthRatioIdx, (float)_videoValidWidth / _videoWidth);
|
||||||
|
break;
|
||||||
|
case PlayAlphaType.BottomSide:
|
||||||
|
newMaterial = new Material(Shader.Find("LeviathanVideo/YUV420P_3D_Alpha_Bottom"));
|
||||||
|
break;
|
||||||
|
case PlayAlphaType.ChromaKey:
|
||||||
|
newMaterial = new Material(Shader.Find("LeviathanVideo/YUV420P_3D_ChromaKey"));
|
||||||
|
break;
|
||||||
|
case PlayAlphaType.None:
|
||||||
|
default:
|
||||||
|
newMaterial = new Material(Shader.Find("LeviathanVideo/YUV420P_3D"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置纹理
|
||||||
|
newMaterial.SetTexture(MainTexIdx, _textures[0]);
|
||||||
|
newMaterial.SetTexture(UTexIdx, _textures[1]);
|
||||||
|
newMaterial.SetTexture(VTexIdx, _textures[2]);
|
||||||
|
|
||||||
|
// 设置Y轴翻转
|
||||||
|
newMaterial.SetFloat("_ReverseY", _reverseY ? 1 : 0);
|
||||||
|
|
||||||
|
// 清理旧材质
|
||||||
|
if (_material != null)
|
||||||
|
{
|
||||||
|
Destroy(_material);
|
||||||
|
}
|
||||||
|
_material = newMaterial;
|
||||||
|
|
||||||
|
// 应用材质到渲染器
|
||||||
|
var materials = meshRenderer.materials;
|
||||||
|
if (_materialIndex >= 0 && _materialIndex < materials.Length)
|
||||||
|
{
|
||||||
|
materials[_materialIndex] = newMaterial;
|
||||||
|
meshRenderer.materials = materials;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meshRenderer.material = newMaterial;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDestroy()
|
||||||
|
{
|
||||||
|
base.OnDestroy();
|
||||||
|
|
||||||
|
// 清理材质
|
||||||
|
if (_material != null)
|
||||||
|
{
|
||||||
|
Destroy(_material);
|
||||||
|
_material = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置是否翻转Y轴
|
||||||
|
/// </summary>
|
||||||
|
public void SetReverseY(bool reverseY)
|
||||||
|
{
|
||||||
|
_reverseY = reverseY;
|
||||||
|
if (_material != null)
|
||||||
|
{
|
||||||
|
_material.SetFloat("_ReverseY", _reverseY ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置材质索引
|
||||||
|
/// </summary>
|
||||||
|
public void SetMaterialIndex(int index)
|
||||||
|
{
|
||||||
|
_materialIndex = index;
|
||||||
|
if (_textures != null && _textures.Length > 0)
|
||||||
|
{
|
||||||
|
OnUpdateMaterial();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
private void OnValidate()
|
||||||
|
{
|
||||||
|
// 使用 delayCall 避免在 OnValidate 中调用 SendMessage 相关操作
|
||||||
|
var currentBytesFile = bytesFile;
|
||||||
|
var lastBytesFile = _lastBytesFile;
|
||||||
|
UnityEditor.EditorApplication.delayCall += () =>
|
||||||
|
{
|
||||||
|
if (this == null) return;
|
||||||
|
|
||||||
|
SetAlphaType(_alphaType);
|
||||||
|
|
||||||
|
// 检测 bytesFile 是否发生变化
|
||||||
|
if (currentBytesFile != lastBytesFile)
|
||||||
|
{
|
||||||
|
_lastBytesFile = currentBytesFile;
|
||||||
|
if (IsPlaying && currentBytesFile != null)
|
||||||
|
{
|
||||||
|
Log($"编辑器中检测到 bytesFile 变化,自动播放新视频");
|
||||||
|
Stop();
|
||||||
|
Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
[CustomEditor(typeof(LeviathanVideo3DRenderer))]
|
||||||
|
public class LeviathanVideo3DRendererEditor : Editor
|
||||||
|
{
|
||||||
|
// 格式化时间:秒转换为 HH:MM:SS.mmm 格式
|
||||||
|
private static string FormatTimeSeconds(double totalSeconds)
|
||||||
|
{
|
||||||
|
int hours = (int)(totalSeconds / 3600);
|
||||||
|
int minutes = (int)((totalSeconds % 3600) / 60);
|
||||||
|
int seconds = (int)(totalSeconds % 60);
|
||||||
|
int milliseconds = (int)((totalSeconds % 1) * 1000);
|
||||||
|
return $"{hours:D2}:{minutes:D2}:{seconds:D2}.{milliseconds:D3}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 格式化时间:微秒转换为 HH:MM:SS.mmm 格式
|
||||||
|
private static string FormatTimeMicroseconds(long microseconds)
|
||||||
|
{
|
||||||
|
return FormatTimeSeconds(microseconds / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
DrawDefaultInspector();
|
||||||
|
var mono = (LeviathanVideo3DRenderer)target;
|
||||||
|
|
||||||
|
// Display video dimensions as read-only fields
|
||||||
|
EditorGUI.BeginDisabledGroup(true);
|
||||||
|
EditorGUILayout.TextField("帧数", $"{mono.PlayFrameIndex} / {mono.FrameCount}");
|
||||||
|
// FrameInterval 单位是秒,Duration 单位是微秒
|
||||||
|
EditorGUILayout.TextField("播放时间", FormatTimeSeconds(mono.PlayFrameIndex * mono.FrameInterval));
|
||||||
|
EditorGUILayout.TextField("总时间", FormatTimeMicroseconds(mono.Duration));
|
||||||
|
EditorGUILayout.TextField("FPS", mono.FrameInterval > 0 ? $"{1.0 / mono.FrameInterval:F2}" : "0");
|
||||||
|
EditorGUILayout.TextField("纹理尺寸", $"{mono.VideoWidth} × {mono.VideoHeight}");
|
||||||
|
EditorGUILayout.TextField("视频有效尺寸", $"{mono.VideoValidWidth} × {mono.VideoHeight}");
|
||||||
|
EditorGUI.EndDisabledGroup();
|
||||||
|
|
||||||
|
{
|
||||||
|
bool oldValue = mono.IsPlaying;
|
||||||
|
// 绘制checkbox
|
||||||
|
bool newValue = EditorGUILayout.Toggle("isPlaying", oldValue);
|
||||||
|
|
||||||
|
// 如果用户切换了checkbox
|
||||||
|
if (oldValue != newValue)
|
||||||
|
{
|
||||||
|
if (newValue)
|
||||||
|
{
|
||||||
|
mono.Play();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mono.Stop();
|
||||||
|
}
|
||||||
|
EditorUtility.SetDirty(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bool oldValue = mono.IsPause;
|
||||||
|
// 绘制checkbox
|
||||||
|
bool newValue = EditorGUILayout.Toggle("isPause", oldValue);
|
||||||
|
|
||||||
|
// 如果用户切换了checkbox
|
||||||
|
if (oldValue != newValue)
|
||||||
|
{
|
||||||
|
if (newValue)
|
||||||
|
{
|
||||||
|
mono.Pause();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mono.Resume();
|
||||||
|
}
|
||||||
|
EditorUtility.SetDirty(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ee83c3bdcef32f449a94eec49cdf005c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,366 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe: UI RawImage 视频渲染组件
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
using UnityEditor;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UI RawImage 视频渲染组件
|
||||||
|
/// 继承自 LeviathanVideoDecoderBase,用于在 UI RawImage 上显示视频
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[RequireComponent(typeof(RawImage))]
|
||||||
|
public unsafe class LeviathanVideoDecoder : LeviathanVideoDecoderBase
|
||||||
|
{
|
||||||
|
private static readonly int ChromaKeyColorId = Shader.PropertyToID("_KeyColor");
|
||||||
|
private static readonly int ChromaKeyCutoffId = Shader.PropertyToID("_ColorCutoff");
|
||||||
|
private static readonly int ChromaKeyColorFeatheringId = Shader.PropertyToID("_ColorFeathering");
|
||||||
|
private static readonly int ChromaKeyMaskFeatheringId = Shader.PropertyToID("_MaskFeathering");
|
||||||
|
private static readonly int ChromaKeySharpeningId = Shader.PropertyToID("_Sharpening");
|
||||||
|
|
||||||
|
private Material ChromaKeyMaterial
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_alphaType != PlayAlphaType.ChromaKey) return null;
|
||||||
|
var rawImage = GetComponent<RawImage>();
|
||||||
|
if (rawImage == null || rawImage.material == null) return null;
|
||||||
|
return rawImage.material.HasProperty(ChromaKeyColorId) ? rawImage.material : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChromaKeyColor(Color color)
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
if (mat != null) mat.SetColor(ChromaKeyColorId, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color GetChromaKeyColor()
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
return mat != null ? mat.GetColor(ChromaKeyColorId) : Color.green;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChromaKeyCutoff(float value)
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
if (mat != null) mat.SetFloat(ChromaKeyCutoffId, Mathf.Clamp01(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetChromaKeyCutoff()
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
return mat != null ? mat.GetFloat(ChromaKeyCutoffId) : 0.2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChromaKeyColorFeathering(float value)
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
if (mat != null) mat.SetFloat(ChromaKeyColorFeatheringId, Mathf.Clamp01(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetChromaKeyColorFeathering()
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
return mat != null ? mat.GetFloat(ChromaKeyColorFeatheringId) : 0.33f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChromaKeyMaskFeathering(float value)
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
if (mat != null) mat.SetFloat(ChromaKeyMaskFeatheringId, Mathf.Clamp01(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetChromaKeyMaskFeathering()
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
return mat != null ? mat.GetFloat(ChromaKeyMaskFeatheringId) : 1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChromaKeySharpening(float value)
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
if (mat != null) mat.SetFloat(ChromaKeySharpeningId, Mathf.Clamp01(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public float GetChromaKeySharpening()
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
return mat != null ? mat.GetFloat(ChromaKeySharpeningId) : 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChromaKeyParams(Color keyColor, float cutoff, float colorFeathering, float maskFeathering, float sharpening)
|
||||||
|
{
|
||||||
|
var mat = ChromaKeyMaterial;
|
||||||
|
if (mat == null) return;
|
||||||
|
mat.SetColor(ChromaKeyColorId, keyColor);
|
||||||
|
mat.SetFloat(ChromaKeyCutoffId, Mathf.Clamp01(cutoff));
|
||||||
|
mat.SetFloat(ChromaKeyColorFeatheringId, Mathf.Clamp01(colorFeathering));
|
||||||
|
mat.SetFloat(ChromaKeyMaskFeatheringId, Mathf.Clamp01(maskFeathering));
|
||||||
|
mat.SetFloat(ChromaKeySharpeningId, Mathf.Clamp01(sharpening));
|
||||||
|
}
|
||||||
|
|
||||||
|
private new static void Log(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.Log("VideoDecoder", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private new static void LogWarning(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.LogWarning("VideoDecoder", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private new static void LogError(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.LogError("VideoDecoder", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用渲染目标
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnEnableRenderTarget()
|
||||||
|
{
|
||||||
|
RawImage rawImage = GetComponent<RawImage>();
|
||||||
|
if (rawImage)
|
||||||
|
{
|
||||||
|
rawImage.enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 禁用渲染目标
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnDisableRenderTarget()
|
||||||
|
{
|
||||||
|
RawImage rawImage = GetComponent<RawImage>();
|
||||||
|
if (rawImage)
|
||||||
|
{
|
||||||
|
rawImage.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新渲染目标尺寸
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnUpdateRenderTargetSize()
|
||||||
|
{
|
||||||
|
RawImage rawImage = GetComponent<RawImage>();
|
||||||
|
if (rawImage)
|
||||||
|
{
|
||||||
|
UpdateImageSize(rawImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化材质
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnInitMaterial()
|
||||||
|
{
|
||||||
|
RawImage rawImage = GetComponent<RawImage>();
|
||||||
|
if (rawImage)
|
||||||
|
{
|
||||||
|
rawImage.texture = _textures[0];
|
||||||
|
UpdateImageMaterial(rawImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新材质
|
||||||
|
/// </summary>
|
||||||
|
protected override void OnUpdateMaterial()
|
||||||
|
{
|
||||||
|
RawImage rawImage = GetComponent<RawImage>();
|
||||||
|
if (rawImage)
|
||||||
|
{
|
||||||
|
UpdateImageMaterial(rawImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void UpdateImageSize(RawImage rawImage)
|
||||||
|
{
|
||||||
|
if (!disableAutoSize)
|
||||||
|
{
|
||||||
|
var videoFrame = VideoFrame;
|
||||||
|
if (videoFrame != null && videoFrame->width > 0)
|
||||||
|
{
|
||||||
|
rawImage.SetNativeSize();
|
||||||
|
rawImage.rectTransform.sizeDelta = _alphaType switch
|
||||||
|
{
|
||||||
|
PlayAlphaType.RightSide => new Vector2(videoFrame->width * 0.5f, videoFrame->height),
|
||||||
|
PlayAlphaType.BottomSide => new Vector2(videoFrame->width, videoFrame->height * 0.5f),
|
||||||
|
_ => new Vector2(videoFrame->width, videoFrame->height)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rawImage.uvRect = new Rect(0, 0, _alphaType == PlayAlphaType.RightSide ? 1 : (float)_videoValidWidth / _videoWidth, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void UpdateImageMaterial(RawImage rawImage)
|
||||||
|
{
|
||||||
|
// 软件解码器使用YUV纹理,需要YUV420P着色器
|
||||||
|
Material newMaterial;
|
||||||
|
switch (_alphaType)
|
||||||
|
{
|
||||||
|
case PlayAlphaType.RightSide:
|
||||||
|
newMaterial = new Material(Shader.Find("LeviathanVideo/YUV420P_Alpha_Right"));
|
||||||
|
newMaterial.SetFloat(ValidWidthRatioIdx, (float)_videoValidWidth / _videoWidth);
|
||||||
|
break;
|
||||||
|
case PlayAlphaType.BottomSide:
|
||||||
|
newMaterial = new Material(Shader.Find("LeviathanVideo/YUV420P_Alpha_Bottom"));
|
||||||
|
break;
|
||||||
|
case PlayAlphaType.ChromaKey:
|
||||||
|
newMaterial = new Material(Shader.Find("LeviathanVideo/YUV420P_ChromaKey"));
|
||||||
|
break;
|
||||||
|
case PlayAlphaType.None:
|
||||||
|
default:
|
||||||
|
newMaterial = new Material(Shader.Find("LeviathanVideo/YUV420P"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
newMaterial.SetTexture(UTexIdx, _textures[1]);
|
||||||
|
newMaterial.SetTexture(VTexIdx, _textures[2]);
|
||||||
|
rawImage.material = newMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
private void OnValidate()
|
||||||
|
{
|
||||||
|
// 使用 delayCall 避免在 OnValidate 中调用 SendMessage 相关操作
|
||||||
|
var currentBytesFile = bytesFile;
|
||||||
|
var lastBytesFile = _lastBytesFile;
|
||||||
|
UnityEditor.EditorApplication.delayCall += () =>
|
||||||
|
{
|
||||||
|
if (this == null) return;
|
||||||
|
|
||||||
|
SetAlphaType(_alphaType);
|
||||||
|
|
||||||
|
// 检测 bytesFile 是否发生变化
|
||||||
|
if (currentBytesFile != lastBytesFile)
|
||||||
|
{
|
||||||
|
_lastBytesFile = currentBytesFile;
|
||||||
|
if (IsPlaying && currentBytesFile != null)
|
||||||
|
{
|
||||||
|
Log($"编辑器中检测到 bytesFile 变化,自动播放新视频");
|
||||||
|
Stop();
|
||||||
|
Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
[CustomEditor(typeof(LeviathanVideoDecoder))]
|
||||||
|
public class LeviathanVideoDecoderEditor : Editor
|
||||||
|
{
|
||||||
|
// 格式化时间:秒转换为 HH:MM:SS.mmm 格式
|
||||||
|
private static string FormatTimeSeconds(double totalSeconds)
|
||||||
|
{
|
||||||
|
int hours = (int)(totalSeconds / 3600);
|
||||||
|
int minutes = (int)((totalSeconds % 3600) / 60);
|
||||||
|
int seconds = (int)(totalSeconds % 60);
|
||||||
|
int milliseconds = (int)((totalSeconds % 1) * 1000);
|
||||||
|
return $"{hours:D2}:{minutes:D2}:{seconds:D2}.{milliseconds:D3}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 格式化时间:微秒转换为 HH:MM:SS.mmm 格式
|
||||||
|
private static string FormatTimeMicroseconds(long microseconds)
|
||||||
|
{
|
||||||
|
return FormatTimeSeconds(microseconds / 1000000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
DrawDefaultInspector();
|
||||||
|
var mono = (LeviathanVideoDecoder)target;
|
||||||
|
|
||||||
|
// Display video dimensions as read-only fields
|
||||||
|
EditorGUI.BeginDisabledGroup(true);
|
||||||
|
EditorGUILayout.TextField("帧数", $"{mono.PlayFrameIndex} / {mono.FrameCount}");
|
||||||
|
// FrameInterval 单位是秒,Duration 单位是微秒
|
||||||
|
EditorGUILayout.TextField("播放时间", FormatTimeSeconds(mono.PlayFrameIndex * mono.FrameInterval));
|
||||||
|
EditorGUILayout.TextField("总时间", FormatTimeMicroseconds(mono.Duration));
|
||||||
|
EditorGUILayout.TextField("FPS", mono.FrameInterval > 0 ? $"{1.0 / mono.FrameInterval:F2}" : "0");
|
||||||
|
EditorGUILayout.TextField("纹理尺寸", $"{mono.VideoWidth} × {mono.VideoHeight}");
|
||||||
|
EditorGUILayout.TextField("视频有效尺寸", $"{mono.VideoValidWidth} × {mono.VideoHeight}");
|
||||||
|
EditorGUI.EndDisabledGroup();
|
||||||
|
|
||||||
|
{
|
||||||
|
bool oldValue = mono.IsPlaying;
|
||||||
|
// 绘制checkbox
|
||||||
|
bool newValue = EditorGUILayout.Toggle("isPlaying", oldValue);
|
||||||
|
|
||||||
|
// 如果用户切换了checkbox
|
||||||
|
if (oldValue != newValue)
|
||||||
|
{
|
||||||
|
if (newValue)
|
||||||
|
{
|
||||||
|
mono.Play();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mono.Stop();
|
||||||
|
}
|
||||||
|
EditorUtility.SetDirty(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
bool oldValue = mono.IsPause;
|
||||||
|
// 绘制checkbox
|
||||||
|
bool newValue = EditorGUILayout.Toggle("isPause", oldValue);
|
||||||
|
|
||||||
|
// 如果用户切换了checkbox
|
||||||
|
if (oldValue != newValue)
|
||||||
|
{
|
||||||
|
if (newValue)
|
||||||
|
{
|
||||||
|
mono.Pause();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mono.Resume();
|
||||||
|
}
|
||||||
|
EditorUtility.SetDirty(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mono.AlphaType == LeviathanVideoDecoderBase.PlayAlphaType.ChromaKey)
|
||||||
|
{
|
||||||
|
DrawChromaKeyParameters(mono);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawChromaKeyParameters(LeviathanVideoDecoder mono)
|
||||||
|
{
|
||||||
|
var rawImage = mono.GetComponent<RawImage>();
|
||||||
|
if (rawImage == null || rawImage.material == null) return;
|
||||||
|
if (!rawImage.material.HasProperty(Shader.PropertyToID("_KeyColor"))) return;
|
||||||
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
EditorGUILayout.LabelField("ChromaKey 参数", EditorStyles.boldLabel);
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
|
||||||
|
Color keyColor = EditorGUILayout.ColorField("KeyColor", mono.GetChromaKeyColor());
|
||||||
|
float cutoff = EditorGUILayout.Slider("Cutoff", mono.GetChromaKeyCutoff(), 0f, 1f);
|
||||||
|
float colorFeathering = EditorGUILayout.Slider("ColorFeathering", mono.GetChromaKeyColorFeathering(), 0f, 1f);
|
||||||
|
float maskFeathering = EditorGUILayout.Slider("MaskFeathering", mono.GetChromaKeyMaskFeathering(), 0f, 1f);
|
||||||
|
float sharpening = EditorGUILayout.Slider("Sharpening", mono.GetChromaKeySharpening(), 0f, 1f);
|
||||||
|
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
mono.SetChromaKeyParams(keyColor, cutoff, colorFeathering, maskFeathering, sharpening);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 56ffe7905c6ea984184ed1b60a985acd
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,927 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe: 视频解码器抽象基类
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
using System.Threading;
|
||||||
|
using UnityEngine;
|
||||||
|
using Unity.Collections;
|
||||||
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 视频解码器抽象基类
|
||||||
|
/// 包含解码逻辑、播放控制、多线程解码等公共功能
|
||||||
|
/// 子类需要实现具体的渲染逻辑
|
||||||
|
/// </summary>
|
||||||
|
public abstract unsafe class LeviathanVideoDecoderBase : MonoBehaviour
|
||||||
|
{
|
||||||
|
protected static readonly int ValidWidthRatioIdx = Shader.PropertyToID("_ValidWidthRatio");
|
||||||
|
protected static readonly int UTexIdx = Shader.PropertyToID("_UTex");
|
||||||
|
protected static readonly int VTexIdx = Shader.PropertyToID("_VTex");
|
||||||
|
protected static readonly int AlphaYTexIdx = Shader.PropertyToID("_AYTex");
|
||||||
|
protected static readonly int AlphaUTexIdx = Shader.PropertyToID("_AUTex");
|
||||||
|
|
||||||
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||||
|
[DllImport("__Internal")]
|
||||||
|
private static extern bool IsWechatMiniGameEnvironment();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 日志辅助方法
|
||||||
|
protected static void Log(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.Log("VideoDecoderBase", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void LogWarning(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.LogWarning("VideoDecoderBase", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void LogError(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.LogError("VideoDecoderBase", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 静态构造函数 - 在类首次使用时执行平台检测
|
||||||
|
/// </summary>
|
||||||
|
static LeviathanVideoDecoderBase()
|
||||||
|
{
|
||||||
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsWCGame = IsWechatMiniGameEnvironment();
|
||||||
|
Log($"微信小游戏平台静态检测: {IsWCGame}");
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
LogError($"微信小游戏平台静态检测异常: {e}");
|
||||||
|
IsWCGame = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
IsWCGame = false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// [LabelText("视频文件(.bytes)")]
|
||||||
|
public TextAsset bytesFile;
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
[System.NonSerialized]
|
||||||
|
protected TextAsset _lastBytesFile;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private ILeviathanDecoder _decoder;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前视频帧指针(子类使用)
|
||||||
|
/// </summary>
|
||||||
|
protected LeviathanVideo.Abstractions.AVFrame* VideoFrame => _decoder != null ? _decoder.VideoFrame : null;
|
||||||
|
|
||||||
|
#if !UNITY_2022_1_OR_NEWER
|
||||||
|
// Unity 2020/2021 兼容:保存数据副本以供解码器使用
|
||||||
|
protected NativeArray<byte> _videoDataBuffer;
|
||||||
|
protected bool _hasVideoDataBuffer = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 平台检测
|
||||||
|
public static bool IsWCGame = false;
|
||||||
|
|
||||||
|
protected const int TextureCount = 3;
|
||||||
|
protected Texture2D[] _textures;
|
||||||
|
protected double _timeAccumulated;
|
||||||
|
protected double _frameInterval;
|
||||||
|
public double FrameInterval => _frameInterval;
|
||||||
|
protected bool _needInitTexture = true;
|
||||||
|
|
||||||
|
protected bool _needApplyTexture = false;
|
||||||
|
|
||||||
|
// 是否为多线程解码
|
||||||
|
protected bool _isMultithreadedDecode;
|
||||||
|
// 多线程相关
|
||||||
|
protected Thread _decodeThread;
|
||||||
|
// 帧状态:0=允许解码下一帧, 1=帧已准备好等待显示
|
||||||
|
protected long _hasFrameReady;
|
||||||
|
|
||||||
|
protected volatile bool _isPlaying;
|
||||||
|
public bool IsPlaying => _isPlaying;
|
||||||
|
|
||||||
|
protected bool _isPause;
|
||||||
|
public bool IsPause => _isPause;
|
||||||
|
|
||||||
|
// 销毁状态标志(防止销毁期间的异步操作继续执行)
|
||||||
|
protected bool _isDestroying = false;
|
||||||
|
|
||||||
|
// 第一帧回调待执行标志(用于从子线程安全地在主线程执行回调)
|
||||||
|
protected volatile bool _pendingFirstFrameCallback = false;
|
||||||
|
|
||||||
|
// ==区间循环专用
|
||||||
|
|
||||||
|
// 每次播放到End, 跳转到的frame
|
||||||
|
protected long _loopBeginFrameIndex = -1;
|
||||||
|
public long LoopBeginFrameIndex => _loopBeginFrameIndex;
|
||||||
|
|
||||||
|
protected long _loopEndFrameIndex = -1;
|
||||||
|
public long LoopEndFrameIndex => _loopEndFrameIndex;
|
||||||
|
|
||||||
|
// 是否正在循环seek中(防止SeekToFrame被多次调用)
|
||||||
|
protected volatile bool _isLoopSeeking = false;
|
||||||
|
|
||||||
|
protected string _codecName = "";
|
||||||
|
|
||||||
|
// 总时长 微秒
|
||||||
|
protected long _duration;
|
||||||
|
public long Duration => _duration;
|
||||||
|
|
||||||
|
protected int _videoWidth;
|
||||||
|
public int VideoWidth => _videoWidth;
|
||||||
|
|
||||||
|
protected int _videoHeight;
|
||||||
|
public int VideoHeight => _videoHeight;
|
||||||
|
|
||||||
|
protected int _videoValidWidth;
|
||||||
|
public int VideoValidWidth => _videoValidWidth;
|
||||||
|
|
||||||
|
public long PlayFrameIndex => _playFrameIndex;
|
||||||
|
protected long _playFrameIndex;
|
||||||
|
|
||||||
|
// 总帧数
|
||||||
|
protected long _frameCount;
|
||||||
|
public long FrameCount => _frameCount;
|
||||||
|
|
||||||
|
protected float _playSpeed = 1.0f;
|
||||||
|
|
||||||
|
public enum PlayAlphaType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
RightSide = 1,
|
||||||
|
BottomSide = 2,
|
||||||
|
ChromaKey = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayAlphaType AlphaType
|
||||||
|
{
|
||||||
|
get => _alphaType;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_alphaType != value)
|
||||||
|
{
|
||||||
|
SetAlphaType(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
protected bool disableAutoSize;
|
||||||
|
[SerializeField]
|
||||||
|
protected bool autoPlayOnStart;
|
||||||
|
|
||||||
|
public bool DisableAutoSize
|
||||||
|
{
|
||||||
|
get => disableAutoSize;
|
||||||
|
set => disableAutoSize = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
protected bool _isLooping = true;
|
||||||
|
|
||||||
|
public bool IsLooping => _isLooping;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 播放完成回调事件(非循环播放时触发)
|
||||||
|
/// </summary>
|
||||||
|
public System.Action OnPlayCompleted;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 首帧渲染完毕回调事件
|
||||||
|
/// 无论同步或异步解码首帧模式都会触发
|
||||||
|
/// </summary>
|
||||||
|
public System.Action OnFirstFrameRendered;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
protected PlayAlphaType _alphaType = PlayAlphaType.None;
|
||||||
|
|
||||||
|
// 上次应用的alphaType,用于检测是否需要更新材质
|
||||||
|
protected PlayAlphaType _lastAppliedAlphaType = PlayAlphaType.None;
|
||||||
|
|
||||||
|
protected virtual void Start()
|
||||||
|
{
|
||||||
|
if (autoPlayOnStart && bytesFile)
|
||||||
|
Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 第一帧解码完成回调(由解码器触发,可能在子线程中调用)
|
||||||
|
/// 设置标志位,实际处理在主线程的 Update 中执行
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void OnFirstFrameDecodedCallback()
|
||||||
|
{
|
||||||
|
_pendingFirstFrameCallback = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理第一帧解码完成的实际逻辑(必须在主线程调用)
|
||||||
|
/// 子类需要重写此方法来处理渲染目标的显示
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void HandleFirstFrameDecoded()
|
||||||
|
{
|
||||||
|
// 先更新纹理,确保显示的是新视频的第一帧
|
||||||
|
DisplayFrame();
|
||||||
|
|
||||||
|
// 子类负责启用渲染目标
|
||||||
|
OnEnableRenderTarget();
|
||||||
|
|
||||||
|
// 触发首帧渲染完毕回调
|
||||||
|
OnFirstFrameRendered?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用渲染目标(子类实现)
|
||||||
|
/// </summary>
|
||||||
|
protected abstract void OnEnableRenderTarget();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 禁用渲染目标(子类实现)
|
||||||
|
/// </summary>
|
||||||
|
protected abstract void OnDisableRenderTarget();
|
||||||
|
|
||||||
|
protected virtual void OnDestroy()
|
||||||
|
{
|
||||||
|
Log("开始销毁,清理所有资源");
|
||||||
|
|
||||||
|
// 立即设置销毁标志,阻止任何新的操作
|
||||||
|
_isDestroying = true;
|
||||||
|
|
||||||
|
_isPlaying = false;
|
||||||
|
|
||||||
|
// 强制同步停止,避免异步操作
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InternalStopSync();
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
LogWarning($"同步停止时出现异常: {e.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release textures
|
||||||
|
if (_textures != null && _textures.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (var tex in _textures)
|
||||||
|
{
|
||||||
|
if (tex) Destroy(tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_textures = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 播放视频
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileData">视频文件</param>
|
||||||
|
/// <param name="playAlpha">播放透明度</param>
|
||||||
|
/// <param name="multithreadedDecode">是否多线程解码</param>
|
||||||
|
/// <param name="beginFrameIndex">开始播放的帧索引</param>
|
||||||
|
/// <param name="syncDecodeFirstFrame">是否同步解码第一帧, 区别在于是否当前帧就能立马看到视频, 会耗时10ms</param>
|
||||||
|
/// <param name="fastDecode">是否启用快速解码(跳过环路滤波器),默认开启以提升性能</param>
|
||||||
|
/// <returns>返回值: 0表示成功, 其他表示错误码</returns>
|
||||||
|
public int PlayVideo(TextAsset fileData, PlayAlphaType playAlpha, bool multithreadedDecode, int beginFrameIndex = 1, bool syncDecodeFirstFrame = true, bool fastDecode = true)
|
||||||
|
{
|
||||||
|
// 如果正在销毁,立即返回
|
||||||
|
if (_isDestroying)
|
||||||
|
{
|
||||||
|
LogWarning("PlayVideo: 组件正在销毁,取消播放");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileData == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
var ret = 0;
|
||||||
|
if (_isPlaying) return ret;
|
||||||
|
|
||||||
|
_playFrameIndex = 0;
|
||||||
|
_timeAccumulated = 0;
|
||||||
|
_isLoopSeeking = false;
|
||||||
|
|
||||||
|
_alphaType = playAlpha;
|
||||||
|
|
||||||
|
#if UNITY_WEBGL
|
||||||
|
// webGL不支持c#多线程
|
||||||
|
_isMultithreadedDecode = false;
|
||||||
|
#else
|
||||||
|
_isMultithreadedDecode = multithreadedDecode;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 根据平台选择解码器
|
||||||
|
if (IsWCGame)
|
||||||
|
{
|
||||||
|
OnDisableRenderTarget();
|
||||||
|
// 创建新的decoder - 使用Worker版本
|
||||||
|
var workerDecoder = new LeviathanWorkerDecoder();
|
||||||
|
workerDecoder.IsLooping = _isLooping; // 设置循环播放状态
|
||||||
|
_decoder = workerDecoder;
|
||||||
|
Log($"[PlayWithData] 创建新的微信小游戏Worker解码器 (静态检测: {IsWCGame}, 循环播放: {_isLooping})");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 只有同步解码第一帧时才立即启用,否则等待第一帧解码完成后再启用
|
||||||
|
if (syncDecodeFirstFrame)
|
||||||
|
{
|
||||||
|
OnEnableRenderTarget();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnDisableRenderTarget();
|
||||||
|
}
|
||||||
|
_decoder = new LeviathanSoftwareDecoder();
|
||||||
|
Log($"[PlayWithData] 使用软件解码器 (静态检测: {IsWCGame})");
|
||||||
|
}
|
||||||
|
_needInitTexture = true;
|
||||||
|
|
||||||
|
// 订阅第一帧回调事件
|
||||||
|
_decoder.OnFirstFrameDecoded += OnFirstFrameDecodedCallback;
|
||||||
|
|
||||||
|
// 初始化解码器
|
||||||
|
bytesFile = fileData;
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
_lastBytesFile = bytesFile;
|
||||||
|
#endif
|
||||||
|
#if UNITY_2022_1_OR_NEWER
|
||||||
|
ret = _decoder.Init(fileData.GetData<byte>(), beginFrameIndex, syncDecodeFirstFrame, fastDecode);
|
||||||
|
#else
|
||||||
|
// Unity 2020/2021: 创建持久的数据副本供解码器使用
|
||||||
|
if (_hasVideoDataBuffer)
|
||||||
|
{
|
||||||
|
_videoDataBuffer.Dispose();
|
||||||
|
}
|
||||||
|
_videoDataBuffer = new NativeArray<byte>(fileData.bytes, Allocator.Persistent);
|
||||||
|
_hasVideoDataBuffer = true;
|
||||||
|
ret = _decoder.Init(_videoDataBuffer, beginFrameIndex, syncDecodeFirstFrame, fastDecode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_frameCount = _decoder.FrameCount;
|
||||||
|
_loopBeginFrameIndex = beginFrameIndex;
|
||||||
|
_loopEndFrameIndex = _frameCount;
|
||||||
|
_duration = _decoder.Duration;
|
||||||
|
_frameInterval = _decoder.FrameInterval;
|
||||||
|
_codecName = _decoder.CodecName;
|
||||||
|
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
LogError($"DecodeNextFrame ret: {ret}");
|
||||||
|
}
|
||||||
|
|
||||||
|
OnUpdateRenderTargetSize();
|
||||||
|
|
||||||
|
// 只有同步解码第一帧时才立即显示,否则等待第一帧解码完成后在 HandleFirstFrameDecoded 中显示
|
||||||
|
if (syncDecodeFirstFrame)
|
||||||
|
{
|
||||||
|
DisplayFrame();
|
||||||
|
// 同步模式下立即触发首帧渲染完毕回调
|
||||||
|
OnFirstFrameRendered?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_isMultithreadedDecode)
|
||||||
|
{
|
||||||
|
// 多线程模式
|
||||||
|
Interlocked.Exchange(ref _hasFrameReady, 1); // 第一帧已准备好
|
||||||
|
_isPlaying = true;
|
||||||
|
_isPause = false;
|
||||||
|
_decodeThread = new Thread(DecodeThreadFunction);
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
_decodeThread.Name = $"{nameof(LeviathanVideoDecoderBase)}.{nameof(DecodeThreadFunction)}";
|
||||||
|
#endif
|
||||||
|
_decodeThread.Start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 单线程模式
|
||||||
|
_isPlaying = true;
|
||||||
|
_isPause = false;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新渲染目标尺寸(子类实现)
|
||||||
|
/// </summary>
|
||||||
|
protected abstract void OnUpdateRenderTargetSize();
|
||||||
|
|
||||||
|
protected void InternalStop()
|
||||||
|
{
|
||||||
|
if (!_isPlaying) return;
|
||||||
|
|
||||||
|
// 立即设置状态,防止重复调用
|
||||||
|
_isPlaying = false;
|
||||||
|
|
||||||
|
// 其他平台的同步停止逻辑
|
||||||
|
InternalStopSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同步停止方法(非微信平台)
|
||||||
|
protected void InternalStopSync()
|
||||||
|
{
|
||||||
|
// 重置第一帧回调标志,避免旧视频的回调影响新视频
|
||||||
|
_pendingFirstFrameCallback = false;
|
||||||
|
_needApplyTexture = false;
|
||||||
|
_isPause = false;
|
||||||
|
|
||||||
|
if (_isMultithreadedDecode)
|
||||||
|
{
|
||||||
|
if (_decodeThread != null && _decodeThread.IsAlive)
|
||||||
|
{
|
||||||
|
_decodeThread.Join(1000); // 添加超时避免死锁
|
||||||
|
if (_decodeThread.IsAlive)
|
||||||
|
{
|
||||||
|
// 强制终止线程
|
||||||
|
_decodeThread.Abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_decodeThread = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其他平台正常销毁decoder
|
||||||
|
if (_decoder != null)
|
||||||
|
{
|
||||||
|
_decoder.OnFirstFrameDecoded -= OnFirstFrameDecodedCallback;
|
||||||
|
_decoder.InternalStop();
|
||||||
|
_decoder.Dispose();
|
||||||
|
_decoder = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !UNITY_2022_1_OR_NEWER
|
||||||
|
// Unity 2020/2021: 释放数据缓冲区
|
||||||
|
if (_hasVideoDataBuffer)
|
||||||
|
{
|
||||||
|
_videoDataBuffer.Dispose();
|
||||||
|
_hasVideoDataBuffer = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
OnDisableRenderTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 主线程
|
||||||
|
protected virtual void Update()
|
||||||
|
{
|
||||||
|
// 如果正在销毁,立即返回
|
||||||
|
if (_isDestroying) return;
|
||||||
|
|
||||||
|
// 处理第一帧回调(从子线程安全地在主线程执行)
|
||||||
|
if (_pendingFirstFrameCallback)
|
||||||
|
{
|
||||||
|
_pendingFirstFrameCallback = false;
|
||||||
|
HandleFirstFrameDecoded();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_isPause) return;
|
||||||
|
if (!_isPlaying) return;
|
||||||
|
|
||||||
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||||
|
_timeAccumulated += 1.0 / Application.targetFrameRate * _playSpeed;
|
||||||
|
#else
|
||||||
|
_timeAccumulated += Time.deltaTime * _playSpeed;
|
||||||
|
#endif
|
||||||
|
if (_isMultithreadedDecode)
|
||||||
|
{
|
||||||
|
// 多线程模式
|
||||||
|
if (_timeAccumulated >= _frameInterval)
|
||||||
|
{
|
||||||
|
// 检查是否有新帧准备好
|
||||||
|
if (Interlocked.Read(ref _hasFrameReady) > 0)
|
||||||
|
{
|
||||||
|
// 复制帧数据到纹理(不立即Apply)
|
||||||
|
DisplayFrame(applyImmediately: false);
|
||||||
|
|
||||||
|
_timeAccumulated -= _frameInterval;
|
||||||
|
|
||||||
|
// DisplayFrame 完成后,通知解码线程可以解码下一帧
|
||||||
|
Interlocked.Exchange(ref _hasFrameReady, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_timeAccumulated > _frameInterval * 3)
|
||||||
|
{
|
||||||
|
_timeAccumulated = _frameInterval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 单线程模式
|
||||||
|
if (IsWCGame)
|
||||||
|
{
|
||||||
|
// Worker解码器:每次Update解码一帧
|
||||||
|
if (_decoder.DecodeNextFrame() == 0)
|
||||||
|
{
|
||||||
|
DisplayFrame(applyImmediately: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 每次Update最多解码一帧,不追帧
|
||||||
|
if (_timeAccumulated >= _frameInterval)
|
||||||
|
{
|
||||||
|
if (_decoder.DecodeNextFrame() == 0)
|
||||||
|
{
|
||||||
|
_timeAccumulated -= _frameInterval;
|
||||||
|
|
||||||
|
long currentFrame = _decoder.DecodedFrameIndex;
|
||||||
|
if (currentFrame >= _loopEndFrameIndex)
|
||||||
|
{
|
||||||
|
if (_isLooping)
|
||||||
|
{
|
||||||
|
SeekToFrame(_loopBeginFrameIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayFrame(applyImmediately: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_timeAccumulated > _frameInterval * 3)
|
||||||
|
{
|
||||||
|
_timeAccumulated = _frameInterval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_playFrameIndex >= _loopEndFrameIndex && !_isLooping)
|
||||||
|
{
|
||||||
|
Pause();
|
||||||
|
OnPlayCompleted?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void LateUpdate()
|
||||||
|
{
|
||||||
|
if (_needApplyTexture) {
|
||||||
|
_needApplyTexture = false;
|
||||||
|
if (_decoder != null && _textures != null)
|
||||||
|
{
|
||||||
|
DisplayFrameApply();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 解码线程(仅多线程模式)
|
||||||
|
protected void DecodeThreadFunction()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (_isPlaying)
|
||||||
|
{
|
||||||
|
if (!_isPause)
|
||||||
|
{
|
||||||
|
// 等待主线程显示完当前帧(_hasFrameReady == 0 表示允许解码下一帧)
|
||||||
|
while (Interlocked.Read(ref _hasFrameReady) != 0 && _isPlaying)
|
||||||
|
{
|
||||||
|
Thread.Sleep(1);
|
||||||
|
}
|
||||||
|
if (!_isPlaying) break;
|
||||||
|
|
||||||
|
// 解码下一帧
|
||||||
|
if (_decoder.DecodeNextFrame() == 0)
|
||||||
|
{
|
||||||
|
// 解码成功,通知主线程帧已准备好
|
||||||
|
Interlocked.Exchange(ref _hasFrameReady, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_playFrameIndex >= _loopEndFrameIndex && !_isLoopSeeking)
|
||||||
|
{
|
||||||
|
if (_isLooping)
|
||||||
|
{
|
||||||
|
_isLoopSeeking = true;
|
||||||
|
SeekToFrame(_loopBeginFrameIndex);
|
||||||
|
// Seek后继续解码,_hasFrameReady 保持为 1,等待主线程显示
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_isPause = true;
|
||||||
|
Interlocked.Exchange(ref _hasFrameReady, 1);
|
||||||
|
// 触发播放完成回调
|
||||||
|
OnPlayCompleted?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Thread.Sleep(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ThreadAbortException)
|
||||||
|
{
|
||||||
|
Thread.ResetAbort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化纹理
|
||||||
|
protected virtual void InitTextures()
|
||||||
|
{
|
||||||
|
if (_textures != null && _textures.Length > 0)
|
||||||
|
{
|
||||||
|
Destroy(_textures[0]);
|
||||||
|
Destroy(_textures[1]);
|
||||||
|
Destroy(_textures[2]);
|
||||||
|
}
|
||||||
|
var videoFrame = _decoder.VideoFrame;
|
||||||
|
// 软件解码器使用YUV格式
|
||||||
|
_textures = new Texture2D[TextureCount];
|
||||||
|
_textures[0] = new Texture2D(videoFrame->linesize[0], videoFrame->height, TextureFormat.Alpha8, false);
|
||||||
|
_textures[1] = new Texture2D(videoFrame->linesize[1], videoFrame->height / 2, TextureFormat.Alpha8, false);
|
||||||
|
_textures[2] = new Texture2D(videoFrame->linesize[2], videoFrame->height / 2, TextureFormat.Alpha8, false);
|
||||||
|
_textures[0].wrapMode = TextureWrapMode.Clamp;
|
||||||
|
_textures[1].wrapMode = TextureWrapMode.Clamp;
|
||||||
|
_textures[2].wrapMode = TextureWrapMode.Clamp;
|
||||||
|
|
||||||
|
_videoValidWidth = videoFrame->width;
|
||||||
|
_videoWidth = videoFrame->linesize[0];
|
||||||
|
_videoHeight = videoFrame->height;
|
||||||
|
|
||||||
|
OnInitMaterial();
|
||||||
|
OnUpdateRenderTargetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化材质(子类实现)
|
||||||
|
/// </summary>
|
||||||
|
protected abstract void OnInitMaterial();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新纹理
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="applyImmediately">是否立即Apply上传到GPU。false时只复制数据,可以稍后调用DisplayFrameApply</param>
|
||||||
|
protected virtual void DisplayFrame(bool applyImmediately = true)
|
||||||
|
{
|
||||||
|
var videoFrame = _decoder.VideoFrame;
|
||||||
|
if (videoFrame->linesize[0] <= 0) return;
|
||||||
|
|
||||||
|
// 检查纹理是否需要重新创建
|
||||||
|
if (_textures == null || _textures[0].width != videoFrame->linesize[0] || _textures[0].height != videoFrame->height)
|
||||||
|
{
|
||||||
|
InitTextures();
|
||||||
|
_lastAppliedAlphaType = _alphaType;
|
||||||
|
_needInitTexture = false;
|
||||||
|
|
||||||
|
if (_decoder is LeviathanWorkerDecoder workerDecoder)
|
||||||
|
{
|
||||||
|
workerDecoder.SetTextureIds(_textures);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_needInitTexture)
|
||||||
|
{
|
||||||
|
// 只在alphaType变化时才更新材质
|
||||||
|
if (_alphaType != _lastAppliedAlphaType)
|
||||||
|
{
|
||||||
|
OnInitMaterial();
|
||||||
|
_lastAppliedAlphaType = _alphaType;
|
||||||
|
}
|
||||||
|
// 如果是Worker版本,将纹理ID传递给JSLIB
|
||||||
|
if (_decoder is LeviathanWorkerDecoder workerDecoder)
|
||||||
|
{
|
||||||
|
workerDecoder.SetTextureIds(_textures);
|
||||||
|
}
|
||||||
|
_needInitTexture = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制帧数据到纹理(需要保护_videoFrame)
|
||||||
|
_decoder.CopyFrameDataToTextures(_textures);
|
||||||
|
|
||||||
|
// 根据参数决定是否立即Apply
|
||||||
|
if (applyImmediately)
|
||||||
|
{
|
||||||
|
_decoder.ApplyTextures(_textures);
|
||||||
|
_needApplyTexture = false; // 立即Apply后,清除延迟标志
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_needApplyTexture = true; // 延迟Apply,设置标志在LateUpdate中执行
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新播放帧索引
|
||||||
|
if (_isMultithreadedDecode)
|
||||||
|
{
|
||||||
|
_playFrameIndex = Interlocked.Read(ref _decoder.GetDecodedFrameIndexRef());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_playFrameIndex = _decoder.DecodedFrameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置循环seek标志
|
||||||
|
_isLoopSeeking = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将纹理数据上传到GPU(可与下一帧解码并行)
|
||||||
|
/// 配合 DisplayFrame(false) 使用,实现分步显示优化
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void DisplayFrameApply()
|
||||||
|
{
|
||||||
|
_decoder.ApplyTextures(_textures);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 跳转到指定时间点
|
||||||
|
public void Seek(double ms)
|
||||||
|
{
|
||||||
|
_decoder.Seek(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 跳转到指定帧
|
||||||
|
public void SeekToFrame(long frame)
|
||||||
|
{
|
||||||
|
_decoder.SeekToFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPlaySpeed(float speed)
|
||||||
|
{
|
||||||
|
_playSpeed = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void SetAlphaType(PlayAlphaType alphaTypeValue)
|
||||||
|
{
|
||||||
|
_alphaType = alphaTypeValue;
|
||||||
|
if (_textures == null || _textures.Length <= 0) return;
|
||||||
|
OnUpdateMaterial();
|
||||||
|
_lastAppliedAlphaType = _alphaType;
|
||||||
|
OnUpdateRenderTargetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新材质(子类实现)
|
||||||
|
/// </summary>
|
||||||
|
protected abstract void OnUpdateMaterial();
|
||||||
|
|
||||||
|
public void SetLooping(bool isLooping)
|
||||||
|
{
|
||||||
|
_isLooping = isLooping;
|
||||||
|
|
||||||
|
// 如果是微信小游戏平台,设置解码器的循环播放状态
|
||||||
|
if (IsWCGame)
|
||||||
|
{
|
||||||
|
_decoder.IsLooping = isLooping;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_isLooping && _isPause)
|
||||||
|
{
|
||||||
|
Resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置循环播放区间, 帧数范围为 1 ~ FrameCount
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="beginFrame">开始帧索引</param>
|
||||||
|
/// <param name="endFrame">结束帧索引</param>
|
||||||
|
public void SetLoopingFrame(long beginFrame, long endFrame)
|
||||||
|
{
|
||||||
|
_loopBeginFrameIndex = beginFrame;
|
||||||
|
_loopEndFrameIndex = endFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 切换视频
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileData">视频文件</param>
|
||||||
|
/// <param name="playAlpha">播放透明度</param>
|
||||||
|
/// <param name="multithreadedDecode">是否多线程解码</param>
|
||||||
|
/// <param name="beginFrameIndex">开始播放的帧索引</param>
|
||||||
|
/// <param name="syncDecodeFirstFrame">是否同步解码第一帧, 区别在于是否当前帧就能立马看到视频, 会耗时10ms</param>
|
||||||
|
/// <param name="fastDecode">是否启用快速解码(跳过环路滤波器),默认开启以提升性能</param>
|
||||||
|
/// <returns>返回值: true表示成功, false表示失败</returns>
|
||||||
|
public bool ChangeVideo(TextAsset fileData, PlayAlphaType playAlpha, bool multithreadedDecode, int beginFrameIndex = 1, bool syncDecodeFirstFrame = true, bool fastDecode = true)
|
||||||
|
{
|
||||||
|
// 如果不同步解码第一帧,先隐藏渲染目标避免显示旧帧
|
||||||
|
if (!syncDecodeFirstFrame)
|
||||||
|
{
|
||||||
|
OnDisableRenderTarget();
|
||||||
|
}
|
||||||
|
return ChangeVideoSync(fileData, playAlpha, multithreadedDecode, beginFrameIndex, syncDecodeFirstFrame, fastDecode);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool ChangeVideoSync(TextAsset fileData, PlayAlphaType playAlpha, bool multithreadedDecode, int beginFrameIndex = 1, bool syncDecodeFirstFrame = true, bool fastDecode = true)
|
||||||
|
{
|
||||||
|
Log("开始同步切换视频");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 同步停止当前视频
|
||||||
|
StopVideoSync();
|
||||||
|
|
||||||
|
// 同步播放新视频
|
||||||
|
int result = PlayVideoSync(fileData, playAlpha, multithreadedDecode, beginFrameIndex, syncDecodeFirstFrame, fastDecode);
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
LogError($"同步播放视频失败,错误码: {result}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log("同步切换视频完成");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (System.Exception e)
|
||||||
|
{
|
||||||
|
LogError($"同步切换视频异常: {e.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void StopVideoSync()
|
||||||
|
{
|
||||||
|
// 立即禁用渲染目标显示,避免显示旧帧
|
||||||
|
OnDisableRenderTarget();
|
||||||
|
|
||||||
|
if (_isPlaying)
|
||||||
|
{
|
||||||
|
if (_isPlaying)
|
||||||
|
{
|
||||||
|
InternalStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同步等待停止操作完成
|
||||||
|
int maxWaitCount = 1000; // 最多等待1000次循环
|
||||||
|
int waitCount = 0;
|
||||||
|
|
||||||
|
while ((_isPlaying) && waitCount < maxWaitCount)
|
||||||
|
{
|
||||||
|
// 在同步模式下,我们不能使用yield,所以使用Thread.Sleep进行短暂等待
|
||||||
|
Thread.Sleep(1);
|
||||||
|
waitCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (waitCount >= maxWaitCount)
|
||||||
|
{
|
||||||
|
LogWarning("同步停止视频超时,继续执行后续操作");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log($"视频同步停止完成,等待了 {waitCount} 次循环");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int PlayVideoSync(TextAsset fileData, PlayAlphaType playAlpha, bool multithreadedDecode, int beginFrameIndex = 1, bool syncDecodeFirstFrame = true, bool fastDecode = true)
|
||||||
|
{
|
||||||
|
// 播放新视频
|
||||||
|
int result;
|
||||||
|
if (fileData != null)
|
||||||
|
{
|
||||||
|
// 使用文件数据播放
|
||||||
|
result = PlayVideo(fileData, playAlpha, multithreadedDecode, beginFrameIndex, syncDecodeFirstFrame, fastDecode);
|
||||||
|
Log($"同步切换到视频资源: {fileData.name}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogError("没有提供有效的视频源");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
LogError($"同步播放视频失败,错误码: {result}");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Play()
|
||||||
|
{
|
||||||
|
if (!Application.isPlaying) return;
|
||||||
|
if (bytesFile == null) return;
|
||||||
|
PlayVideo(bytesFile, _alphaType, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
if (!Application.isPlaying) return;
|
||||||
|
InternalStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Pause()
|
||||||
|
{
|
||||||
|
if (!Application.isPlaying) return;
|
||||||
|
_isPause = true;
|
||||||
|
|
||||||
|
// 调用解码器的暂停方法
|
||||||
|
_decoder?.Pause(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Resume()
|
||||||
|
{
|
||||||
|
if (!Application.isPlaying) return;
|
||||||
|
_isPause = false;
|
||||||
|
|
||||||
|
// 调用解码器的恢复方法
|
||||||
|
_decoder?.Pause(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5515e1e1db39d4348a3a57571c7bc460
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: edd271292fe97374fa02eaba7183c305
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,590 @@
|
|||||||
|
/*----------------------------------------------------------------
|
||||||
|
// Copyright (C) 2025 Beijing All rights reserved.
|
||||||
|
//
|
||||||
|
// Author: huachangmiao
|
||||||
|
// Create Date: 2025/04/11
|
||||||
|
// Module Describe:
|
||||||
|
//----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
//******************************************************************
|
||||||
|
// CPU软解码
|
||||||
|
// 适用平台
|
||||||
|
// Editor
|
||||||
|
// Windows
|
||||||
|
// MacOS
|
||||||
|
// Android
|
||||||
|
// iOS
|
||||||
|
// WebGL
|
||||||
|
//******************************************************************
|
||||||
|
|
||||||
|
// #define ENABLE_COPY_NATIVE_DATA //复制Native数据到托管内存
|
||||||
|
|
||||||
|
#if UNITY_WEBGL
|
||||||
|
#else
|
||||||
|
#define ENABLE_AV_MALLOC //使用AV_MALLOC分配内存
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using LeviathanVideo.Abstractions;
|
||||||
|
using LeviathanVideo.Bindings.Linked;
|
||||||
|
using Unity.Collections;
|
||||||
|
using Unity.Collections.LowLevel.Unsafe;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using AOT;
|
||||||
|
|
||||||
|
internal unsafe class LeviathanSoftwareDecoder : ILeviathanDecoder
|
||||||
|
{
|
||||||
|
// 日志辅助方法
|
||||||
|
private static void Log(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.Log("SoftwareDecoder", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LogWarning(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.LogWarning("SoftwareDecoder", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LogError(string message)
|
||||||
|
{
|
||||||
|
LeviathanLogConfig.LogError("SoftwareDecoder", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 事件实现
|
||||||
|
public event Action OnFirstFrameDecoded;
|
||||||
|
private AVFormatContext* _pFormatContext;
|
||||||
|
private AVCodecContext* _pVideoContext;
|
||||||
|
|
||||||
|
private int _videoStreamIndex;
|
||||||
|
private AVFrame* _videoFrame;
|
||||||
|
private AVPacket* _packet;
|
||||||
|
|
||||||
|
private AVIOContext* _pAvioCtx;
|
||||||
|
private byte* _avioCtxBuffer;
|
||||||
|
private BufferData _bufferData;
|
||||||
|
private GCHandle _bdHandle;
|
||||||
|
|
||||||
|
#if ENABLE_AV_MALLOC
|
||||||
|
#else
|
||||||
|
private GCHandle _hAvioBuffer;
|
||||||
|
#endif
|
||||||
|
#if ENABLE_COPY_NATIVE_DATA
|
||||||
|
private IntPtr _unmanagedPtr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 私有字段
|
||||||
|
private long _frameCount;
|
||||||
|
private double _frameInterval;
|
||||||
|
private string _codecName = "";
|
||||||
|
private long _duration;
|
||||||
|
private long _decodedFrameIndex;
|
||||||
|
private bool _firstFrameDecoded = false;
|
||||||
|
|
||||||
|
// 线程安全锁 - 保护 Seek 和 Decode 操作不并发执行
|
||||||
|
private readonly object _codecLock = new object();
|
||||||
|
|
||||||
|
// 实现接口属性
|
||||||
|
public long FrameCount => _frameCount;
|
||||||
|
public double FrameInterval => _frameInterval;
|
||||||
|
public string CodecName => _codecName;
|
||||||
|
public long Duration => _duration;
|
||||||
|
public long DecodedFrameIndex => _decodedFrameIndex;
|
||||||
|
public AVFrame* VideoFrame => _videoFrame;
|
||||||
|
|
||||||
|
// 循环播放属性(软件解码器不需要特殊处理)
|
||||||
|
public bool IsLooping { get; set; } = false;
|
||||||
|
|
||||||
|
// 快速解码模式(跳过环路滤波器)
|
||||||
|
private bool _fastDecode = true;
|
||||||
|
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct BufferData
|
||||||
|
{
|
||||||
|
public byte* ptr;
|
||||||
|
public byte* originPtr;
|
||||||
|
public ulong size;
|
||||||
|
public ulong totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MonoPInvokeCallback(typeof(avio_alloc_context_read_packet))]
|
||||||
|
private static int ReadPacket(void* opaque, byte* buf, int bufSize)
|
||||||
|
{
|
||||||
|
BufferData* bd = (BufferData*)opaque;
|
||||||
|
bufSize = (int)Math.Min(bd->size, (ulong)bufSize);
|
||||||
|
|
||||||
|
if (bufSize <= 0)
|
||||||
|
return leviathan.AVERROR_EOF;
|
||||||
|
|
||||||
|
// Buffer.MemoryCopy(bd->ptr, buf, bufSize, bufSize);
|
||||||
|
UnsafeUtility.MemCpy(buf, bd->ptr, bufSize);
|
||||||
|
bd->ptr += bufSize;
|
||||||
|
bd->size -= (ulong)bufSize;
|
||||||
|
|
||||||
|
return bufSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MonoPInvokeCallback(typeof(avio_alloc_context_seek))]
|
||||||
|
private static long SeekPacket(void* opaque, long offset, int whence)
|
||||||
|
{
|
||||||
|
BufferData* bd = (BufferData*)opaque;
|
||||||
|
switch (whence)
|
||||||
|
{
|
||||||
|
case 0: //SEEK_SET
|
||||||
|
if (offset < 0 || (ulong)offset > bd->totalSize)
|
||||||
|
return leviathan.AVERROR_Enum(leviathan.EINVAL);
|
||||||
|
bd->ptr = bd->originPtr + offset;
|
||||||
|
bd->size = bd->totalSize - (ulong)offset;
|
||||||
|
return offset;
|
||||||
|
|
||||||
|
case 1: //SEEK_CUR
|
||||||
|
long newPos = bd->ptr - bd->originPtr + offset;
|
||||||
|
if (newPos < 0 || (ulong)newPos > bd->totalSize)
|
||||||
|
return leviathan.AVERROR_Enum(leviathan.EINVAL);
|
||||||
|
bd->ptr += offset;
|
||||||
|
bd->size = bd->totalSize - (ulong)newPos;
|
||||||
|
return newPos;
|
||||||
|
|
||||||
|
case 2: //SEEK_END
|
||||||
|
long endPos = (long)bd->totalSize + offset;
|
||||||
|
if (endPos < 0 || endPos > (long)bd->totalSize)
|
||||||
|
return leviathan.AVERROR_Enum(leviathan.EINVAL);
|
||||||
|
bd->ptr = bd->originPtr + endPos;
|
||||||
|
bd->size = bd->totalSize - (ulong)endPos;
|
||||||
|
return endPos;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return leviathan.AVERROR_Enum(leviathan.EINVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int Init(NativeArray<byte> fileData, int beginFrameIndex = 1, bool syncDecodeFirstFrame = true, bool fastDecode = true)
|
||||||
|
{
|
||||||
|
LinkedBindings.Initialize();
|
||||||
|
_fastDecode = fastDecode;
|
||||||
|
var ret = 0;
|
||||||
|
var src = fileData.GetUnsafeReadOnlyPtr();
|
||||||
|
|
||||||
|
#if ENABLE_COPY_NATIVE_DATA
|
||||||
|
_unmanagedPtr = Marshal.AllocHGlobal(fileData.Length);
|
||||||
|
var dst = _unmanagedPtr.ToPointer();
|
||||||
|
UnsafeUtility.MemCpy(dst, src, fileData.Length);
|
||||||
|
src = dst;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ulong bufferSize = (ulong)fileData.Length;
|
||||||
|
|
||||||
|
_bufferData = new BufferData
|
||||||
|
{
|
||||||
|
originPtr = (byte*)src, // 初始化原始指针
|
||||||
|
ptr = (byte*)src,
|
||||||
|
size = bufferSize,
|
||||||
|
totalSize = bufferSize
|
||||||
|
};
|
||||||
|
_bdHandle = GCHandle.Alloc(_bufferData, GCHandleType.Pinned);
|
||||||
|
|
||||||
|
avio_alloc_context_read_packet readCallback = ReadPacket;
|
||||||
|
avio_alloc_context_seek seekCallback = SeekPacket;
|
||||||
|
|
||||||
|
// 为AVIOContext分配缓冲区
|
||||||
|
const int avioCtxBufferSize = 4096;
|
||||||
|
#if ENABLE_AV_MALLOC
|
||||||
|
_avioCtxBuffer = (byte*)leviathan.av_malloc(avioCtxBufferSize);
|
||||||
|
|
||||||
|
// 分配AVIOContext并将其与AVFormatContext关联
|
||||||
|
_pAvioCtx = leviathan.avio_alloc_context(
|
||||||
|
_avioCtxBuffer,
|
||||||
|
avioCtxBufferSize,
|
||||||
|
0, // 不可写
|
||||||
|
(void*)_bdHandle.AddrOfPinnedObject(),
|
||||||
|
readCallback,
|
||||||
|
null, // 无写回调
|
||||||
|
seekCallback
|
||||||
|
);
|
||||||
|
#else
|
||||||
|
// wasm无法直接使用av_malloc
|
||||||
|
int alignment = 64;
|
||||||
|
byte[] avioBufferManaged = new byte[avioCtxBufferSize + alignment - 1];
|
||||||
|
_hAvioBuffer = GCHandle.Alloc(avioBufferManaged, GCHandleType.Pinned);
|
||||||
|
IntPtr avioBufferPtr = _hAvioBuffer.AddrOfPinnedObject();
|
||||||
|
// 调整指针到对齐地址
|
||||||
|
IntPtr alignedPtr = new IntPtr((avioBufferPtr.ToInt64() + alignment - 1) & ~(alignment - 1));
|
||||||
|
|
||||||
|
// 分配AVIOContext并将其与AVFormatContext关联
|
||||||
|
_pAvioCtx = leviathan.avio_alloc_context(
|
||||||
|
(byte*)alignedPtr,
|
||||||
|
avioCtxBufferSize,
|
||||||
|
0, // 不可写
|
||||||
|
(void*)_bdHandle.AddrOfPinnedObject(),
|
||||||
|
readCallback,
|
||||||
|
null, // 无写回调
|
||||||
|
seekCallback
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
if (_pAvioCtx == null)
|
||||||
|
{
|
||||||
|
ret = leviathan.AVERROR_Enum(leviathan.ENOMEM);
|
||||||
|
LogError("无法分配AVIO上下文");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
_pFormatContext = leviathan.avformat_alloc_context();
|
||||||
|
_pFormatContext->pb = _pAvioCtx;
|
||||||
|
var pFormatContext = _pFormatContext;
|
||||||
|
ret = leviathan.avformat_open_input(&pFormatContext, null, null, null);
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
LogError($"avformat_open_input failed: {ret}");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
if (_pFormatContext == null)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return InternalPlay(beginFrameIndex, syncDecodeFirstFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int InternalPlay(int beginFrameIndex = 1, bool syncDecodeFirstFrame = true)
|
||||||
|
{
|
||||||
|
leviathan.avformat_find_stream_info(_pFormatContext, null);
|
||||||
|
AVCodec* videoCodec = null;
|
||||||
|
_videoStreamIndex = leviathan.av_find_best_stream(_pFormatContext, AVMediaType.AVMEDIA_TYPE_VIDEO, -1, -1, &videoCodec, 0);
|
||||||
|
// 获取视频流信息
|
||||||
|
AVStream* videoStream = _pFormatContext->streams[_videoStreamIndex];
|
||||||
|
// 计算帧间隔
|
||||||
|
AVRational frameRate = videoStream->r_frame_rate;
|
||||||
|
double fps = leviathan.av_q2d(frameRate);
|
||||||
|
_frameInterval = 1.0 / fps;
|
||||||
|
|
||||||
|
_pVideoContext = leviathan.avcodec_alloc_context3(videoCodec);
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
_codecName = leviathan.avcodec_get_name(videoCodec->id);
|
||||||
|
#endif
|
||||||
|
if (videoCodec == null)
|
||||||
|
{
|
||||||
|
LogError("videoCodec is null");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
_pVideoContext->thread_count = 0;
|
||||||
|
_pVideoContext->thread_type = leviathan.FF_THREAD_FRAME | leviathan.FF_THREAD_SLICE;
|
||||||
|
|
||||||
|
// 根据 fastDecode 参数决定是否跳过环路滤波器以提升解码速度
|
||||||
|
if (_fastDecode)
|
||||||
|
{
|
||||||
|
_pVideoContext->skip_loop_filter = (AVDiscard)48; //AVDISCARD_ALL
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug.Log($"{_pVideoContext->codec_id} {_frameInterval} {_pFormatContext->duration}");
|
||||||
|
leviathan.avcodec_open2(_pVideoContext, videoCodec, null);
|
||||||
|
|
||||||
|
_duration = _pFormatContext->duration;
|
||||||
|
|
||||||
|
if (_pFormatContext->streams[_videoStreamIndex]->nb_frames > 0)
|
||||||
|
{
|
||||||
|
_frameCount = _pFormatContext->streams[_videoStreamIndex]->nb_frames;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dur = _duration / 1000.0 * leviathan.av_q2d(videoStream->time_base);
|
||||||
|
int frNum = frameRate.num;
|
||||||
|
int frDen = frameRate.den;
|
||||||
|
if (dur > 0 && frNum > 0 && frDen > 0)
|
||||||
|
{
|
||||||
|
_frameCount = (long)(dur * frNum / frDen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Debug.Log($"frameCount: {_frameCount}");
|
||||||
|
|
||||||
|
_videoFrame = leviathan.av_frame_alloc();
|
||||||
|
_packet = leviathan.av_packet_alloc();
|
||||||
|
|
||||||
|
if (beginFrameIndex > 1)
|
||||||
|
{
|
||||||
|
SeekToFrame(beginFrameIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syncDecodeFirstFrame)
|
||||||
|
{
|
||||||
|
// 第一帧同步解码
|
||||||
|
int ret = DecodeNextFrame();
|
||||||
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
LogError($"DecodeNextFrame ret: {ret}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int DecodeNextFrame()
|
||||||
|
{
|
||||||
|
lock (_codecLock)
|
||||||
|
{
|
||||||
|
if (_pVideoContext == null || _pFormatContext == null)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return DecodeNextFrameInternal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int DecodeNextFrameInternal()
|
||||||
|
{
|
||||||
|
var flushSent = false;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var error = leviathan.avcodec_receive_frame(_pVideoContext, _videoFrame);
|
||||||
|
if (error == 0)
|
||||||
|
{
|
||||||
|
long frameIndex = 1;
|
||||||
|
if (_frameInterval > 0)
|
||||||
|
{
|
||||||
|
var timeBase = _pFormatContext->streams[_videoStreamIndex]->time_base;
|
||||||
|
double frameTime = _videoFrame->pts * leviathan.av_q2d(timeBase);
|
||||||
|
frameIndex = (long)(frameTime / _frameInterval + 0.1) + 1;
|
||||||
|
}
|
||||||
|
Interlocked.Exchange(ref _decodedFrameIndex, frameIndex);
|
||||||
|
|
||||||
|
// 触发第一帧回调
|
||||||
|
if (!_firstFrameDecoded)
|
||||||
|
{
|
||||||
|
_firstFrameDecoded = true;
|
||||||
|
OnFirstFrameDecoded?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error == leviathan.AVERROR_Enum(leviathan.EAGAIN))
|
||||||
|
{
|
||||||
|
if (flushSent)
|
||||||
|
{
|
||||||
|
// 已发送过flush,无更多数据
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = leviathan.av_read_frame(_pFormatContext, _packet);
|
||||||
|
if (error < 0)
|
||||||
|
{
|
||||||
|
if (error == leviathan.AVERROR_EOF)
|
||||||
|
{
|
||||||
|
// 发送flush packet以取出解码器中剩余帧
|
||||||
|
error = leviathan.avcodec_send_packet(_pVideoContext, null);
|
||||||
|
flushSent = true;
|
||||||
|
if (error < 0 && error != leviathan.AVERROR_Enum(leviathan.EAGAIN))
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 其他错误,继续尝试读取
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_packet->stream_index == _videoStreamIndex)
|
||||||
|
{
|
||||||
|
error = leviathan.avcodec_send_packet(_pVideoContext, _packet);
|
||||||
|
if (error < 0)
|
||||||
|
{
|
||||||
|
leviathan.av_packet_unref(_packet);
|
||||||
|
if (error == leviathan.AVERROR_Enum(leviathan.EAGAIN))
|
||||||
|
{
|
||||||
|
// 解码器需要先输出帧,继续循环处理
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
leviathan.av_packet_unref(_packet);
|
||||||
|
}
|
||||||
|
else if (error == leviathan.AVERROR_EOF)
|
||||||
|
{
|
||||||
|
// 解码器已无更多帧
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 其他错误
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InternalStop()
|
||||||
|
{
|
||||||
|
lock (_codecLock)
|
||||||
|
{
|
||||||
|
// Release resources
|
||||||
|
var pVideoContext = _pVideoContext;
|
||||||
|
var pFormatContext = _pFormatContext;
|
||||||
|
var videoFrame = _videoFrame;
|
||||||
|
var packet = _packet;
|
||||||
|
if (_pVideoContext != null) leviathan.avcodec_free_context(&pVideoContext);
|
||||||
|
if (_pFormatContext != null) leviathan.avformat_close_input(&pFormatContext);
|
||||||
|
if (_videoFrame != null) leviathan.av_frame_free(&videoFrame);
|
||||||
|
if (_packet != null) leviathan.av_packet_free(&packet);
|
||||||
|
|
||||||
|
_pVideoContext = null;
|
||||||
|
_pFormatContext = null;
|
||||||
|
_videoFrame = null;
|
||||||
|
_packet = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_pAvioCtx != null)
|
||||||
|
{
|
||||||
|
#if ENABLE_AV_MALLOC
|
||||||
|
leviathan.av_free(_pAvioCtx->buffer);
|
||||||
|
#else
|
||||||
|
_pAvioCtx->buffer = null; // 关键:阻止 FFmpeg 调用 av_free
|
||||||
|
if (_hAvioBuffer.IsAllocated)
|
||||||
|
{
|
||||||
|
_hAvioBuffer.Free();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
var pAvioCtx = _pAvioCtx;
|
||||||
|
leviathan.avio_context_free(&pAvioCtx);
|
||||||
|
_pAvioCtx = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_bdHandle.IsAllocated)
|
||||||
|
{
|
||||||
|
_bdHandle.Free();
|
||||||
|
}
|
||||||
|
_bdHandle = default;
|
||||||
|
#if ENABLE_COPY_NATIVE_DATA
|
||||||
|
if (_unmanagedPtr != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
Marshal.FreeHGlobal(_unmanagedPtr);
|
||||||
|
}
|
||||||
|
_unmanagedPtr = default;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
InternalStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 跳转到指定时间点
|
||||||
|
public void Seek(double ms)
|
||||||
|
{
|
||||||
|
lock (_codecLock)
|
||||||
|
{
|
||||||
|
if (_pVideoContext == null || _pFormatContext == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
long targetFrame = (long)(_frameInterval * ms);
|
||||||
|
// Debug.Log("Seek to " + targetFrame + "(" + ms + "ms)");
|
||||||
|
leviathan.avformat_seek_file(_pFormatContext, _videoStreamIndex, Int64.MinValue, targetFrame, Int64.MaxValue, leviathan.AVSEEK_FLAG_FRAME);
|
||||||
|
leviathan.avcodec_flush_buffers(_pVideoContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 跳转到指定帧
|
||||||
|
public void SeekToFrame(long frame)
|
||||||
|
{
|
||||||
|
lock (_codecLock)
|
||||||
|
{
|
||||||
|
if (_pVideoContext == null || _pFormatContext == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
long pts = _pFormatContext->streams[_videoStreamIndex]->duration / _frameCount * frame - 1;
|
||||||
|
leviathan.avformat_seek_file(_pFormatContext, _videoStreamIndex, Int64.MinValue, pts, Int64.MaxValue, leviathan.AVSEEK_FLAG_FRAME);
|
||||||
|
leviathan.avcodec_flush_buffers(_pVideoContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取decodedFrameIndex的引用,用于Interlocked操作
|
||||||
|
public ref long GetDecodedFrameIndexRef()
|
||||||
|
{
|
||||||
|
return ref _decodedFrameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 暂停/恢复播放的空方法(软件解码器不需要特殊处理)
|
||||||
|
public void Pause(bool pause)
|
||||||
|
{
|
||||||
|
// 软件解码器的暂停由LeviathanVideoDecoder的_isPause标志控制
|
||||||
|
// 这里不需要额外的实现
|
||||||
|
}
|
||||||
|
|
||||||
|
// 微信平台特有方法的空实现
|
||||||
|
public int GetDecoderStatus()
|
||||||
|
{
|
||||||
|
// 软件解码器始终返回已启动状态
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将视频帧数据复制到纹理(需要在信号保护下执行,访问_videoFrame)
|
||||||
|
public void CopyFrameDataToTextures(UnityEngine.Texture2D[] textures)
|
||||||
|
{
|
||||||
|
const int TextureCount = 3;
|
||||||
|
|
||||||
|
if (textures == null || textures.Length < TextureCount) return;
|
||||||
|
|
||||||
|
// 更新YUV纹理 - 只做SetPixelData,不做Apply
|
||||||
|
for (uint i = 0; i < TextureCount; i++)
|
||||||
|
{
|
||||||
|
if (_videoFrame->data[i] == null || textures[i] == null) continue;
|
||||||
|
|
||||||
|
var nativeArray = Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<byte>(
|
||||||
|
_videoFrame->data[i],
|
||||||
|
textures[i].width * textures[i].height,
|
||||||
|
Unity.Collections.Allocator.None
|
||||||
|
);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
#if ENABLE_UNITY_COLLECTIONS_CHECKS
|
||||||
|
Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref nativeArray, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.Create());
|
||||||
|
#endif
|
||||||
|
// 只复制数据到纹理的CPU缓冲区,不上传到GPU
|
||||||
|
textures[i].SetPixelData(nativeArray, 0);
|
||||||
|
#if ENABLE_UNITY_COLLECTIONS_CHECKS
|
||||||
|
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.Release(Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.GetAtomicSafetyHandle(nativeArray));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
catch (UnityException)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
nativeArray.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将纹理数据应用到GPU(可以和下一帧解码并行执行)
|
||||||
|
public void ApplyTextures(UnityEngine.Texture2D[] textures)
|
||||||
|
{
|
||||||
|
const int TextureCount = 3;
|
||||||
|
|
||||||
|
if (textures == null || textures.Length < TextureCount) return;
|
||||||
|
|
||||||
|
// 将CPU数据上传到GPU - 不需要访问_videoFrame
|
||||||
|
for (uint i = 0; i < TextureCount; i++)
|
||||||
|
{
|
||||||
|
if (textures[i] == null) continue;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
textures[i].Apply(false, false);
|
||||||
|
}
|
||||||
|
catch (UnityException)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8483db06286d50244a0f52a17aa423e0
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 373be47a4cbf74440b38b8262a3b7ded
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7e114e8876509a14b8fae1de0eef5764
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
Shader "LeviathanVideo/YUV420P"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
[PerRendererData] _MainTex ("YTexture", 2D) = "white" {}
|
||||||
|
_UTex("UTexture",2D)="white"{}
|
||||||
|
_VTex("VTexture",2D)="white"{}
|
||||||
|
[Toggle]_ReverseY("Reverse Y",Float)=1
|
||||||
|
|
||||||
|
_Color ("Tint", Color) = (1,1,1,1)
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
|
||||||
|
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"Queue"="Transparent"
|
||||||
|
"IgnoreProjector"="True"
|
||||||
|
"RenderType"="Transparent"
|
||||||
|
"PreviewType"="Plane"
|
||||||
|
"CanUseSpriteAtlas"="True"
|
||||||
|
}
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Cull Off
|
||||||
|
Lighting Off
|
||||||
|
ZWrite Off
|
||||||
|
ZTest [unity_GUIZTestMode]
|
||||||
|
Blend SrcAlpha OneMinusSrcAlpha
|
||||||
|
ColorMask [_ColorMask]
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "Default"
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityUI.cginc"
|
||||||
|
|
||||||
|
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||||
|
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
#if UNITY_VERSION < 202100
|
||||||
|
inline half3 UIGammaToLinear(half3 value)
|
||||||
|
{
|
||||||
|
return value * (value * (value * 0.305306011h + 0.682171111h) + 0.012522878h);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//Rec.709
|
||||||
|
static const half3x3 YUV_TO_RGB = half3x3(
|
||||||
|
1.16438, 1.16438, 1.16438,
|
||||||
|
0.0, -0.21325, 2.11240,
|
||||||
|
1.79274, -0.53291, 0.0
|
||||||
|
);
|
||||||
|
|
||||||
|
struct appdata_t
|
||||||
|
{
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
float4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f
|
||||||
|
{
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
float4 worldPosition : TEXCOORD1;
|
||||||
|
float4 mask : TEXCOORD2;
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
sampler2D _MainTex,_UTex,_VTex;
|
||||||
|
fixed4 _Color;
|
||||||
|
fixed4 _TextureSampleAdd;
|
||||||
|
float4 _ClipRect;
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
float _UIMaskSoftnessX;
|
||||||
|
float _UIMaskSoftnessY;
|
||||||
|
int _UIVertexColorAlwaysGammaSpace;
|
||||||
|
half _ReverseY;
|
||||||
|
|
||||||
|
v2f vert(appdata_t v)
|
||||||
|
{
|
||||||
|
v2f OUT;
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||||
|
float4 vPosition = UnityObjectToClipPos(v.vertex);
|
||||||
|
OUT.worldPosition = v.vertex;
|
||||||
|
OUT.vertex = vPosition;
|
||||||
|
|
||||||
|
float2 pixelSize = vPosition.w;
|
||||||
|
pixelSize /= float2(1, 1) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||||
|
|
||||||
|
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
|
||||||
|
float2 maskUV = (v.vertex.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
|
||||||
|
OUT.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex);
|
||||||
|
if (_ReverseY>0)
|
||||||
|
{
|
||||||
|
OUT.texcoord.y=1- OUT.texcoord.y;
|
||||||
|
}
|
||||||
|
OUT.mask = float4(v.vertex.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + abs(pixelSize.xy)));
|
||||||
|
|
||||||
|
|
||||||
|
if (_UIVertexColorAlwaysGammaSpace)
|
||||||
|
{
|
||||||
|
if(!IsGammaSpace())
|
||||||
|
{
|
||||||
|
v.color.rgb = UIGammaToLinear(v.color.rgb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OUT.color = v.color * _Color;
|
||||||
|
return OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed4 frag(v2f IN) : SV_Target
|
||||||
|
{
|
||||||
|
//Round up the alpha color coming from the interpolator (to 1.0/256.0 steps)
|
||||||
|
//The incoming alpha could have numerical instability, which makes it very sensible to
|
||||||
|
//HDR color transparency blend, when it blends with the world's texture.
|
||||||
|
const half alphaPrecision = half(0xff);
|
||||||
|
const half invAlphaPrecision = half(1.0 / alphaPrecision);
|
||||||
|
IN.color.a = round(IN.color.a * alphaPrecision) * invAlphaPrecision;
|
||||||
|
half3 c = 0;
|
||||||
|
c.r = (tex2D(_MainTex, IN.texcoord)).a-(16/255.0);
|
||||||
|
c.g = (tex2D(_UTex, IN.texcoord) ).a-(128/255.0);
|
||||||
|
c.b = (tex2D(_VTex, IN.texcoord) ).a-(128/255.0);
|
||||||
|
c=mul(c,YUV_TO_RGB);
|
||||||
|
|
||||||
|
half4 color = half4(c,IN.color.a);
|
||||||
|
color.rgb = saturate(color*_Color);
|
||||||
|
#ifdef UNITY_COLORSPACE_GAMMA
|
||||||
|
#else
|
||||||
|
color.rgb = pow(color.rgb, 2.2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef UNITY_UI_CLIP_RECT
|
||||||
|
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||||
|
color.a *= m.x * m.y;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef UNITY_UI_ALPHACLIP
|
||||||
|
clip (color.a - 0.001);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return color * IN.color;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: beb8b637c3a75a24aa0de903c96638e1
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures: []
|
||||||
|
nonModifiableTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
Shader "LeviathanVideo/YUV420P_3D"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_MainTex ("YTexture", 2D) = "white" {}
|
||||||
|
_UTex("UTexture",2D)="white"{}
|
||||||
|
_VTex("VTexture",2D)="white"{}
|
||||||
|
[Toggle]_ReverseY("Reverse Y",Float)=1
|
||||||
|
|
||||||
|
_Color ("Tint", Color) = (1,1,1,1)
|
||||||
|
|
||||||
|
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull Mode", Float) = 2
|
||||||
|
[Enum(Off, 0, On, 1)] _ZWrite ("ZWrite", Float) = 1
|
||||||
|
[Enum(UnityEngine.Rendering.CompareFunction)] _ZTest ("ZTest", Float) = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"Queue"="Transparent"
|
||||||
|
"IgnoreProjector"="True"
|
||||||
|
"RenderType"="Transparent"
|
||||||
|
}
|
||||||
|
|
||||||
|
Cull [_Cull]
|
||||||
|
Lighting Off
|
||||||
|
ZWrite [_ZWrite]
|
||||||
|
ZTest [_ZTest]
|
||||||
|
Blend SrcAlpha OneMinusSrcAlpha
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "Default"
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert
|
||||||
|
#pragma fragment frag
|
||||||
|
#pragma target 2.0
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
//Rec.709
|
||||||
|
static const half3x3 YUV_TO_RGB = half3x3(
|
||||||
|
1.16438, 1.16438, 1.16438,
|
||||||
|
0.0, -0.21325, 2.11240,
|
||||||
|
1.79274, -0.53291, 0.0
|
||||||
|
);
|
||||||
|
|
||||||
|
struct appdata_t
|
||||||
|
{
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
float4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
struct v2f
|
||||||
|
{
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float2 texcoord : TEXCOORD0;
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
sampler2D _MainTex,_UTex,_VTex;
|
||||||
|
fixed4 _Color;
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
half _ReverseY;
|
||||||
|
|
||||||
|
v2f vert(appdata_t v)
|
||||||
|
{
|
||||||
|
v2f OUT;
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||||
|
OUT.vertex = UnityObjectToClipPos(v.vertex);
|
||||||
|
OUT.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex);
|
||||||
|
if (_ReverseY > 0)
|
||||||
|
{
|
||||||
|
OUT.texcoord.y = 1 - OUT.texcoord.y;
|
||||||
|
}
|
||||||
|
OUT.color = v.color * _Color;
|
||||||
|
return OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed4 frag(v2f IN) : SV_Target
|
||||||
|
{
|
||||||
|
half3 c = 0;
|
||||||
|
c.r = (tex2D(_MainTex, IN.texcoord)).a - (16/255.0);
|
||||||
|
c.g = (tex2D(_UTex, IN.texcoord)).a - (128/255.0);
|
||||||
|
c.b = (tex2D(_VTex, IN.texcoord)).a - (128/255.0);
|
||||||
|
c = mul(c, YUV_TO_RGB);
|
||||||
|
|
||||||
|
half4 color = half4(c, IN.color.a);
|
||||||
|
color.rgb = saturate(color * _Color);
|
||||||
|
#ifdef UNITY_COLORSPACE_GAMMA
|
||||||
|
#else
|
||||||
|
color.rgb = pow(color.rgb, 2.2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return color * IN.color;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user