Remove legacy godot_extension

This commit is contained in:
2025-09-28 16:40:28 +09:00
parent 33ba584de1
commit af31da2296
12 changed files with 50 additions and 2591 deletions

View File

@@ -72,11 +72,17 @@ D:\Project\video-av1\
│ └── ios/
│ └── VavCore.xcodeproj # iOS용 .a 빌드용 Xcode 프로젝트
├── godot_extension/ # (예정) Godot 익스텐션 및 C# 래퍼 개발
── VavCoreGodot.sln # C# 래퍼 및 Godot 노드용 솔루션
├── src/
├── VavCore.Wrapper/ # C# P/Invoke 래퍼 클래스
│ │ ── VavCore.Godot/ # Godot 커스텀 노드 구현
├── platforms/ # ✅ 플랫폼별 구조로 개편 완료
── windows/
├── vavcore/ # VavCore Windows 라이브러리
├── godot-plugin/ # ✅ Godot Extension (완전 구현)
── VavCoreGodot.sln # C# 래퍼 및 Godot 노드용 솔루션
│ │ ├── src/
│ │ │ ├── VavCore.Wrapper/ # C# P/Invoke 래퍼 클래스
│ │ │ └── VavCore.Godot/ # Godot 커스텀 노드 구현
│ │ └── libs/windows-x86_64/ # Windows DLL들
│ ├── applications/ # Windows 애플리케이션들
│ └── tests/ # 테스트 프로젝트들
│ ├── project.godot # 익스텐션 테스트/개발용 Godot 프로젝트
│ └── shaders/
│ └── yuv_to_rgb.gdshader
@@ -108,10 +114,11 @@ D:\Project\video-av1\
- **Android 플랫폼**: MediaCodec 통합, dav1d 크로스 컴파일, CMake 빌드 시스템 완료
- 각 프로젝트는 `vav2/VavCore/src`의 공용 소스를 참조한다.
- **`vav2/godot_extension/`** ✅ (완료)
- Godot 엔진 플러그인 개발하고 테스트하는 전용 공간이다.
- `VavCore.Wrapper`: 네이티브 라이브러리의 C 함수를 호출하는 저수준 C# P/Invoke 코드 포함한다. **실제 VavCore C API에 맞춰 28개 함수로 단순화 완료**
- `VavCore.Godot`: `VavCore.Wrapper`를 사용하여 Godot 에디터에서 사용할 수 있는 커스텀 노드(예: `VavCorePlayerNode`) 구현한다.
- **`vav2/platforms/windows/godot-plugin/`** ✅ (완료)
- Windows 전용 Godot 엔진 플러그인 개발 테스트 공간
- `VavCore.Wrapper`: Windows VavCore DLL의 C 함수를 호출하는 저수준 C# P/Invoke 코드 포함. **실제 VavCore C API에 맞춰 28개 함수로 단순화 완료**
- `VavCore.Godot`: `VavCore.Wrapper`를 사용하여 Godot 에디터에서 사용할 수 있는 커스텀 노드(예: `VavCorePlayerNode`) 구현
- **플랫폼별 구조**: Windows 특화 최적화 및 NVDEC/VPL/AMF 하드웨어 가속 지원
- **API 설계 철학**: 작고 간편한 player-centric 디자인으로 기술부채 최소화
- **`vav2/libs_output/`** (예정)
@@ -119,7 +126,7 @@ D:\Project\video-av1\
## 4. Godot 애드온 배포 및 사용
`vav2/godot_extension`에서 개발된 결과물은 다른 Godot 프로젝트에서 쉽게 사용할 수 있는 '애드온' 형태로 배포된다.
`vav2/platforms/windows/godot-plugin`에서 개발된 결과물은 다른 Godot 프로젝트에서 쉽게 사용할 수 있는 '애드온' 형태로 배포된다.
### 4.1. 소비자 프로젝트 예시 (`GodotPlayer`)
@@ -159,7 +166,7 @@ D:\MyGames\GodotPlayer\
- **dav1d Android 빌드**: ARM64/ARM32 크로스 컴파일 완료
- **CMake 빌드 시스템**: Android NDK 통합 및 라이브러리 빌드
- **platforms/android/godot-plugin**: Godot 4.4.1 Android 네이티브 플러그인 완료
- **godot_extension C# wrapper**: VavCore C API 기반 P/Invoke 레이어 완료
- **platforms/windows/godot-plugin C# wrapper**: VavCore C API 기반 P/Invoke 레이어 완료
- **API 설계 단순화**: 70+ 함수에서 28개 vavcore_* 함수로 축소
### 5.2. 현재 진행 중 🔄

View File

@@ -1,159 +0,0 @@
using System;
using VavCore.Wrapper;
namespace VavCoreTest;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("=== VavCore.Wrapper P/Invoke Test ===");
Console.WriteLine();
// Test 1: Library Initialization
Console.WriteLine("Test 1: Library Initialization");
try
{
bool initialized = VavCoreWrapper.Initialize();
Console.WriteLine($" VavCore.Initialize(): {(initialized ? "SUCCESS" : "FAILED")}");
if (initialized)
{
Console.WriteLine($" Library is initialized: {VavCoreWrapper.IsInitialized}");
}
}
catch (Exception ex)
{
Console.WriteLine($" ERROR: {ex.Message}");
Console.WriteLine($" Exception Type: {ex.GetType().Name}");
Console.WriteLine($" Stack Trace: {ex.StackTrace}");
}
Console.WriteLine();
// Test 2: Version Information
Console.WriteLine("Test 2: Version Information");
try
{
string version = VavCoreWrapper.GetVersion();
Console.WriteLine($" VavCore Version: {version}");
}
catch (Exception ex)
{
Console.WriteLine($" ERROR getting version: {ex.Message}");
}
Console.WriteLine();
// Test 3: Platform Information
Console.WriteLine("Test 3: Platform Information");
try
{
string libraryName = VavCoreTypes.GetLibraryName();
Console.WriteLine($" Library Name: {libraryName}");
var optimalDecoder = VavCoreTypes.GetOptimalDecoderType();
Console.WriteLine($" Optimal Decoder: {optimalDecoder}");
var optimalSurface = VavCoreTypes.GetOptimalSurfaceType();
Console.WriteLine($" Optimal Surface: {optimalSurface}");
}
catch (Exception ex)
{
Console.WriteLine($" ERROR getting platform info: {ex.Message}");
}
Console.WriteLine();
// Test 4: Player Creation and Basic Operations
Console.WriteLine("Test 4: Player Creation and Basic Operations");
VavCoreWrapper? player = null;
try
{
player = new VavCoreWrapper();
Console.WriteLine(" Player created successfully");
// Test basic properties
Console.WriteLine($" Player handle: 0x{player.NativeHandle:X}");
// Test decoder capabilities
bool supportsAuto = player.SupportsSurfaceType(VavCoreTypes.SurfaceType.Auto);
bool supportsCPU = player.SupportsSurfaceType(VavCoreTypes.SurfaceType.CPU);
bool supportsD3D11 = player.SupportsSurfaceType(VavCoreTypes.SurfaceType.D3D11Texture);
Console.WriteLine($" Supports Auto Surface: {supportsAuto}");
Console.WriteLine($" Supports CPU Surface: {supportsCPU}");
Console.WriteLine($" Supports D3D11 Surface: {supportsD3D11}");
// Get optimal surface type for this player
var playerOptimalSurface = player.GetOptimalSurfaceType();
Console.WriteLine($" Player Optimal Surface: {playerOptimalSurface}");
}
catch (Exception ex)
{
Console.WriteLine($" ERROR creating player: {ex.Message}");
}
finally
{
player?.Dispose();
Console.WriteLine(" Player disposed");
}
Console.WriteLine();
// Test 5: Static Utility Methods
Console.WriteLine("Test 5: Static Utility Methods");
try
{
string availableDecoders = VavCoreWrapper.GetAvailableDecoders();
Console.WriteLine($" Available Decoders: {availableDecoders}");
var optimalDecoderType = VavCoreWrapper.GetOptimalDecoderType();
Console.WriteLine($" Static Optimal Decoder: {optimalDecoderType}");
var optimalSurfaceType = VavCoreWrapper.GetOptimalSurfaceType("vulkan");
Console.WriteLine($" Static Optimal Surface (Vulkan): {optimalSurfaceType}");
bool av1Supported = VavCoreWrapper.IsCodecSupported(VavCoreTypes.VideoCodecType.AV1);
bool vp9Supported = VavCoreWrapper.IsCodecSupported(VavCoreTypes.VideoCodecType.VP9);
Console.WriteLine($" AV1 Codec Supported: {av1Supported}");
Console.WriteLine($" VP9 Codec Supported: {vp9Supported}");
}
catch (Exception ex)
{
Console.WriteLine($" ERROR in utility methods: {ex.Message}");
}
Console.WriteLine();
// Test 6: Error Handling
Console.WriteLine("Test 6: Error Handling");
try
{
string successMsg = VavCoreWrapper.GetErrorMessage(VavCoreTypes.VavCoreResult.Success);
string errorMsg = VavCoreWrapper.GetErrorMessage(VavCoreTypes.VavCoreResult.ErrorFileNotFound);
Console.WriteLine($" Success Message: {successMsg}");
Console.WriteLine($" Error Message: {errorMsg}");
}
catch (Exception ex)
{
Console.WriteLine($" ERROR in error handling: {ex.Message}");
}
Console.WriteLine();
// Test 7: Library Cleanup
Console.WriteLine("Test 7: Library Cleanup");
try
{
VavCoreWrapper.Cleanup();
Console.WriteLine(" VavCore.Cleanup(): SUCCESS");
Console.WriteLine($" Library is initialized: {VavCoreWrapper.IsInitialized}");
}
catch (Exception ex)
{
Console.WriteLine($" ERROR during cleanup: {ex.Message}");
}
Console.WriteLine();
Console.WriteLine("=== VavCore.Wrapper Test Completed ===");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}

View File

@@ -1,702 +0,0 @@
# VavCore Godot 4.4.1 Extension - 완전 구현 완료
크로스 플랫폼 C# Extension으로 Godot 4.4.1에서 하드웨어 가속 AV1 비디오 디코딩을 제공하는 완전 구현된 라이브러리입니다.
## ✅ **완전 구현된 주요 기능**
### **🚀 하드웨어 가속 AV1 디코딩 (완료)**
- **Windows**: ✅ NVIDIA NVDEC, Intel VPL, AMD AMF, Media Foundation 모든 디코더 구현 완료
- **크로스 플랫폼**: ✅ Linux, macOS, Android, iOS 모든 플랫폼 지원 구조 완성
- **자동 감지**: ✅ 최적 하드웨어 디코더 자동 선택 (nvdec → vpl → amf → dav1d)
- **소프트웨어 fallback**: ✅ 하드웨어 미지원 시 dav1d 자동 전환
### **🎮 Godot 4.4.1 통합 (완료)**
- **VavCore C API**: ✅ 28개 vavcore_* 함수 완전 구현 및 DLL 빌드 성공
- **VavCore.Wrapper**: ✅ P/Invoke C# 래퍼 완전 구현 (빌드 성공)
- **Zero-Copy GPU Pipeline**: ✅ 플랫폼별 GPU Surface 직접 바인딩 구현
- **CPU Fallback 시스템**: ✅ 저사양 디바이스용 완전한 소프트웨어 렌더링
- **이중 렌더링 모드**: ✅ GPU Surface + CPU ImageTexture 양방향 지원
### **🔧 크로스 플랫폼 아키텍처 (완료)**
- **VavCore.Wrapper**: ✅ 28개 C API 함수의 완전한 P/Invoke 래퍼
- **VavCore.Godot**: ✅ Godot 전용 노드 및 유틸리티 완성
- **플랫폼별 Surface 지원**: ✅ Vulkan, OpenGL, D3D11, Metal 모든 GPU API 지원
- **RenderingDevice 통합**: ✅ Godot 4.4.1 RenderingDevice API 완전 활용
## 📁 **완성된 프로젝트 구조**
```
vav2/platforms/windows/godot-plugin/ # 플랫폼별 구조로 재편성 완료
├── VavCoreGodot.sln # Visual Studio 솔루션 (빌드 성공)
├── src/
│ ├── VavCore.Wrapper/ # ✅ P/Invoke 래퍼 (완전 구현)
│ │ ├── VavCore.Wrapper.csproj # .NET 6.0 라이브러리 (빌드 성공)
│ │ ├── VavCoreTypes.cs # ✅ C API 매칭 C# 데이터 타입
│ │ ├── VavCoreNative.cs # ✅ 28개 P/Invoke 선언 완료
│ │ └── VavCoreWrapper.cs # ✅ 고수준 C# 래퍼 완료
│ └── VavCore.Godot/ # ✅ Godot Extension (완전 구현)
│ ├── VavCore.Godot.csproj # Godot 4.4.1 프로젝트 (빌드 성공)
│ ├── Nodes/ # ✅ Godot 노드들
│ │ ├── VavCoreVideoPlayer.cs # ✅ 완전한 비디오 플레이어
│ │ ├── VavCoreVideoTexture.cs # ✅ YUV→RGB 변환 텍스처
│ │ └── VavCoreVideoStream.cs # ✅ 저수준 스트림 제어
│ ├── Resources/ # ✅ Godot 리소스
│ │ ├── VavCoreVideoFile.cs # ✅ 비디오 파일 메타데이터
│ │ └── VavCoreDecoderSettings.cs # ✅ 디코더 설정
│ ├── Utilities/ # ✅ 헬퍼 유틸리티
│ │ ├── VavCoreGodotUtils.cs # ✅ 플랫폼 감지 및 최적화
│ │ └── VavCoreImageConverter.cs # ✅ YUV→RGB 변환 최적화
│ └── Plugin/ # ✅ 에디터 통합
│ └── VavCorePlugin.cs # ✅ 에디터 플러그인
├── libs/windows-x86_64/ # ✅ 네이티브 라이브러리
│ ├── VavCore.dll # ✅ 빌드된 VavCore DLL
│ ├── dav1d.dll # ✅ dav1d 라이브러리
│ └── [GPU 라이브러리들] # ✅ NVDEC/VPL/AMF 지원
└── demo/ # ✅ 데모 프로젝트
└── vavcore-demo/ # ✅ 완전 구현된 Godot 데모
```
## 🚀 **설치 및 사용법**
### **1. 필요 조건 (모두 구현 완료)**
- **Godot 4.4.1** with C# support ✅
- **.NET 8.0 SDK** ✅ (현재 프로젝트에서 사용 중)
- **Visual Studio 2022** ✅ (빌드 환경 구성 완료)
- **VavCore 라이브러리**: ✅ 완전 구현 및 빌드 완료
- **VavCore C API**: ✅ 28개 vavcore_* 함수 모두 구현
### **2. Extension 빌드 (검증 완료)**
```bash
# 플랫폼별 디렉토리로 이동
cd vav2/platforms/windows/godot-plugin/
# NuGet 패키지 복원 (성공 확인)
dotnet restore
# 전체 솔루션 빌드 (성공 확인)
dotnet build --configuration Debug
dotnet build --configuration Release
# 개별 프로젝트 빌드
dotnet build src/VavCore.Wrapper/VavCore.Wrapper.csproj --configuration Debug
dotnet build src/VavCore.Godot/VavCore.Godot.csproj --configuration Debug
# 빌드 결과 확인
# → VavCore.Wrapper.dll 생성 완료
# → VavCore.Godot.dll 생성 완료
# → 일부 경고만 있음 (기능에 영향 없음)
```
### **3. Godot 프로젝트에 설치 (실제 구현됨)**
#### **Option A: 데모 프로젝트 사용 (추천)**
```bash
# 완전 구현된 데모 프로젝트 실행
cd godot-projects/vavcore-demo/
# Godot 4.4.1에서 project.godot 열기
# → VavCorePlayer 노드가 씬에 이미 설정됨
# → Load Video, Play, Pause, Stop 버튼 모두 작동
# → 실제 AV1 프레임 디코딩 및 렌더링 완료
```
#### **Option B: 기존 프로젝트에 통합**
```xml
<!-- Godot 프로젝트의 .csproj 파일에 추가 -->
<ItemGroup>
<ProjectReference Include="vav2/platforms/windows/godot-plugin/src/VavCore.Godot/VavCore.Godot.csproj" />
</ItemGroup>
```
#### **Option C: 빌드된 DLL 직접 복사**
```bash
# 빌드된 DLL들을 Godot 프로젝트로 복사
cp bin/Debug/VavCore.Wrapper.dll /path/to/godot/project/
cp bin/Debug/VavCore.Godot.dll /path/to/godot/project/
# 네이티브 라이브러리 복사 (Windows)
cp libs/windows-x86_64/VavCore.dll /path/to/godot/project/
cp libs/windows-x86_64/dav1d.dll /path/to/godot/project/
```
## 🎮 **실제 구현된 사용 예제**
### **완전 구현된 VavCorePlayer (실제 동작)**
```csharp
// godot-projects/vavcore-demo/scripts/VavCorePlayer.cs - 실제 구현 파일
using Godot;
using System;
using System.Runtime.InteropServices;
public partial class VavCorePlayer : Control
{
// ✅ 실제 구현된 핵심 기능들
private IntPtr decoderHandle = IntPtr.Zero;
private Image yuvImage;
private ImageTexture yuvTexture;
private ShaderMaterial yuvMaterial;
// ✅ 텍스처 캐싱 최적화 (실제 구현됨)
private bool isTextureInitialized = false;
public override void _Ready()
{
GD.Print("VavCore Demo: Initializing...");
GD.Print("Checking for VavCore Extension...");
// ✅ VavCore DLL 로드 확인 (실제 P/Invoke)
if (!CheckVavCoreAvailability())
{
GD.PrintErr("VavCore Extension not available");
return;
}
// ✅ YUV to RGB 셰이더 로드 (실제 구현됨)
SetupYUVShader();
GD.Print("VavCore Player initialized successfully");
}
// ✅ 실제 비디오 로드 기능 (VavCore DLL 연동)
public bool LoadVideo(string filePath)
{
GD.Print($"Loading video: {filePath}");
// VavCore C API 호출 (실제 P/Invoke)
decoderHandle = vavcore_create_decoder();
if (decoderHandle == IntPtr.Zero)
{
GD.PrintErr("Failed to create VavCore decoder");
return false;
}
// 비디오 파일 열기
int result = vavcore_open_file(decoderHandle, filePath);
if (result != 0)
{
GD.PrintErr($"Failed to open video file: {result}");
return false;
}
GD.Print("Video loaded successfully");
return true;
}
// ✅ 실제 프레임 디코딩 및 렌더링 (GPU/CPU 하이브리드)
private void DecodeAndRenderFrame()
{
// VavCore에서 프레임 디코딩
var frame = new VavCoreVideoFrame();
int result = vavcore_decode_frame(decoderHandle, ref frame);
if (result == 0) // 성공
{
// ✅ GPU Pipeline 시도
if (!TryGPUSurfaceRendering(frame))
{
// ✅ CPU Fallback (완전 구현됨)
CreateYUVTextures(frame);
}
}
}
// ✅ 실제 P/Invoke 함수들 (28개 vavcore_* 함수)
[DllImport("VavCore.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr vavcore_create_decoder();
[DllImport("VavCore.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int vavcore_open_file(IntPtr handle, string filePath);
[DllImport("VavCore.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int vavcore_decode_frame(IntPtr handle, ref VavCoreVideoFrame frame);
// ... 25개 추가 vavcore_* 함수들
}
```
### **GPU/CPU 하이브리드 렌더링 시스템 (실제 구현됨)**
```csharp
// ✅ Zero-Copy GPU Pipeline 구현
private bool TryGPUSurfaceRendering(VavCoreVideoFrame frame)
{
// 플랫폼별 GPU Surface 바인딩 시도
var renderingServer = RenderingServer.Singleton;
var device = renderingServer.GetRenderingDevice();
if (device != null)
{
// Vulkan/D3D11/Metal Surface 직접 바인딩
return UpdateGPUSurfaceTextures(frame, device);
}
return false; // GPU 실패 시 CPU Fallback
}
// ✅ CPU Fallback 렌더링 (완전 구현됨)
private void CreateYUVTextures(VavCoreVideoFrame frame)
{
// 텍스처 캐싱 최적화
if (!isTextureInitialized)
{
CreateSingleBlockYUVTexture(frame); // 단일 블록 복사 최적화
isTextureInitialized = true;
}
else
{
UpdateYUVTexture(frame); // ImageTexture.Update() 사용
}
}
// ✅ 단일 블록 YUV 복사 최적화 (실제 구현됨)
private void CreateSingleBlockYUVTexture(VavCoreVideoFrame frame)
{
// 진정한 단일 블록 복사: 1회 Buffer.MemoryCopy
uint totalSize = frame.y_size + frame.u_size + frame.v_size;
var yuvData = new byte[totalSize];
unsafe
{
byte* srcPtr = (byte*)frame.y_plane.ToPointer();
fixed (byte* dstPtr = yuvData)
{
Buffer.MemoryCopy(srcPtr, dstPtr, totalSize, totalSize);
}
}
// 전체 YUV 데이터를 하나의 1D 텍스처로 생성
var yuvImage = Image.CreateFromData((int)totalSize, 1, false, Image.Format.R8, yuvData);
yuvTexture = ImageTexture.CreateFromImage(yuvImage);
// 셰이더에 오프셋 정보 전달
yuvMaterial.SetShaderParameter("yuv_texture", yuvTexture);
yuvMaterial.SetShaderParameter("y_offset", 0);
yuvMaterial.SetShaderParameter("u_offset", (int)frame.y_size);
yuvMaterial.SetShaderParameter("v_offset", (int)(frame.y_size + frame.u_size));
yuvMaterial.SetShaderParameter("frame_width", (int)frame.width);
yuvMaterial.SetShaderParameter("frame_height", (int)frame.height);
}
// ✅ BT.709 YUV→RGB 변환 셰이더 (실제 파일)
private void SetupYUVShader()
{
var shader = GD.Load<Shader>("res://shaders/yuv_to_rgb.gdshader");
yuvMaterial = new ShaderMaterial();
yuvMaterial.Shader = shader;
// 단일 블록 + 3개 텍스처 양방향 지원
GetNode<ColorRect>("VideoRect").Material = yuvMaterial;
}
```
### **실제 하드웨어 디코더 선택 시스템 (구현 완료)**
```csharp
// ✅ 자동 최적 디코더 선택 (실제 VavCore C API)
public bool InitializeWithOptimalDecoder()
{
// VavCore에서 지원하는 디코더 목록 확인
IntPtr decoders = vavcore_get_available_decoders();
// 우선순위: NVDEC → VPL → AMF → Media Foundation → dav1d
string[] priority = { "nvdec", "vpl", "amf", "media_foundation", "dav1d" };
foreach (string decoderName in priority)
{
if (vavcore_is_decoder_available(decoders, decoderName))
{
GD.Print($"Using optimal decoder: {decoderName}");
decoderHandle = vavcore_create_decoder_by_name(decoderName);
return decoderHandle != IntPtr.Zero;
}
}
GD.PrintErr("No suitable decoder found");
return false;
}
// ✅ 플랫폼별 GPU API 지원 확인
private bool CheckGPUAccelerationSupport()
{
var renderingServer = RenderingServer.Singleton;
string apiName = renderingServer.GetRenderingDriverName();
switch (apiName)
{
case "Vulkan":
return CheckVulkanSupport();
case "D3D11":
return CheckD3D11Support();
case "OpenGL3":
return CheckOpenGLSupport();
case "Metal":
return CheckMetalSupport();
default:
GD.Print($"Unsupported GPU API: {apiName}, using CPU fallback");
return false;
}
}
// ✅ VavCore DLL 가용성 확인 (실제 P/Invoke)
private bool CheckVavCoreAvailability()
{
try
{
int version = vavcore_get_version();
GD.Print($"VavCore version: {version}");
return version > 0;
}
catch (DllNotFoundException)
{
GD.PrintErr("VavCore.dll not found");
return false;
}
catch (Exception ex)
{
GD.PrintErr($"VavCore initialization failed: {ex.Message}");
return false;
}
}
```
### **실제 비디오 메타데이터 추출 (VavCore C API)**
```csharp
// ✅ 실제 구현된 메타데이터 추출 함수들
public void DisplayVideoMetadata(string filePath)
{
IntPtr decoder = vavcore_create_decoder();
int result = vavcore_open_file(decoder, filePath);
if (result == 0)
{
// VavCore C API로 메타데이터 추출
var metadata = new VavCoreVideoMetadata();
vavcore_get_metadata(decoder, ref metadata);
// 실제 출력되는 정보들
GD.Print($"Resolution: {metadata.width}x{metadata.height}");
GD.Print($"Duration: {metadata.duration_seconds:F2} seconds");
GD.Print($"Frame rate: {metadata.frame_rate:F2} FPS");
GD.Print($"Total frames: {metadata.total_frames}");
GD.Print($"Codec: {Marshal.PtrToStringAnsi(metadata.codec_name)}");
// 지원되는 디코더 목록
IntPtr availableDecoders = vavcore_get_available_decoders();
PrintAvailableDecoders(availableDecoders);
vavcore_destroy_decoder(decoder);
}
else
{
GD.PrintErr($"Failed to open video file: {result}");
}
}
// ✅ 실제 데이터 구조체 (VavCore C API 매칭)
[StructLayout(LayoutKind.Sequential)]
public struct VavCoreVideoMetadata
{
public uint width;
public uint height;
public double frame_rate;
public double duration_seconds;
public ulong total_frames;
public IntPtr codec_name; // char*
public uint format; // YUV format
}
// ✅ Main.cs - 실제 UI 연동 (완전 구현됨)
public partial class Main : Control
{
private VavCorePlayer player;
private void OnLoadButtonPressed()
{
// 실제 파일 다이얼로그는 현재 하드코딩
string testVideoPath = "D:/Project/video-av1/sample/simple_test.webm";
if (player.LoadVideo(testVideoPath))
{
GetNode<Label>("StatusLabel").Text = "Video loaded successfully";
GetNode<Button>("PlayButton").Disabled = false;
}
else
{
GetNode<Label>("StatusLabel").Text = "Failed to load video";
}
}
private void OnPlayButtonPressed()
{
player.StartPlayback();
GetNode<Label>("StatusLabel").Text = "Playing";
}
private void OnStopButtonPressed()
{
player.StopPlayback();
GetNode<Label>("StatusLabel").Text = "Stopped";
}
}
```
## 🔧 **실제 구현된 최적화 기능들**
### **텍스처 캐싱 최적화 (구현 완료)**
```csharp
// ✅ 첫 프레임: 텍스처 생성
if (!isTextureInitialized)
{
CreateSingleBlockYUVTexture(frame);
isTextureInitialized = true;
}
// ✅ 이후 프레임: ImageTexture.Update()로 빠른 업데이트
else
{
yuvTexture.Update(newYUVImage);
}
```
### **단일 블록 메모리 복사 (구현 완료)**
```csharp
// ✅ 기존 3번 복사 → 1번 복사로 최적화
// 3번 Array.Copy 대신 1번 Buffer.MemoryCopy 사용
uint totalSize = frame.y_size + frame.u_size + frame.v_size;
Buffer.MemoryCopy(srcPtr, dstPtr, totalSize, totalSize);
```
### **GPU/CPU 하이브리드 렌더링 (구현 완료)**
```csharp
// ✅ GPU 우선 시도, 실패 시 CPU fallback
if (!TryGPUSurfaceRendering(frame))
{
CreateYUVTextures(frame); // CPU fallback
}
```
### **플랫폼별 GPU API 지원 (구현 완료)**
```csharp
// ✅ 플랫폼별 GPU Surface 바인딩 시스템
private bool UpdateGPUSurfaceTextures(VavCoreVideoFrame frame, RenderingDevice device)
{
string apiName = RenderingServer.Singleton.GetRenderingDriverName();
switch (apiName)
{
case "Vulkan":
return UpdateVulkanSurfaceTextures(frame, device);
case "D3D11":
return UpdateD3D11SurfaceTextures(frame, device);
case "OpenGL3":
return UpdateOpenGLSurfaceTextures(frame, device);
case "Metal":
return UpdateMetalSurfaceTextures(frame, device);
default:
GD.Print($"API {apiName} not supported, using CPU fallback");
return false;
}
}
// ✅ Vulkan Surface 직접 바인딩 (Zero-Copy)
private bool UpdateVulkanSurfaceTextures(VavCoreVideoFrame frame, RenderingDevice device)
{
try
{
// VavCore GPU Surface → Vulkan Texture 직접 바인딩
var yTextureRD = device.TextureCreateFromExtension(
RenderingDevice.TextureType.Type2D,
Image.Format.R8,
frame.gpu_y_surface, // GPU surface handle
(uint)frame.width,
(uint)frame.height
);
// UV 텍스처도 동일하게 바인딩
var uvTextureRD = device.TextureCreateFromExtension(
RenderingDevice.TextureType.Type2D,
Image.Format.Rg8,
frame.gpu_uv_surface,
(uint)frame.width / 2,
(uint)frame.height / 2
);
// 셰이더에 RenderingDevice 텍스처 전달
yuvMaterial.SetShaderParameter("y_texture_rd", yTextureRD);
yuvMaterial.SetShaderParameter("uv_texture_rd", uvTextureRD);
return true;
}
catch (Exception ex)
{
GD.PrintErr($"Vulkan surface binding failed: {ex.Message}");
return false;
}
}
```
## 📊 **실제 성능 결과 및 모니터링**
### **완료된 최적화 성능**
```csharp
// ✅ 실제 측정된 성능 개선 효과
// - 텍스처 캐싱: 첫 프레임 생성 후 Update()로 빠른 처리
// - 단일 블록 복사: 3번 Array.Copy → 1번 Buffer.MemoryCopy
// - GPU Pipeline: Zero-Copy Surface 바인딩으로 메모리 복사 제거
// - CPU Fallback: GPU 실패 시에도 안정적인 소프트웨어 렌더링
// ✅ VavCore C API 성능 통계 (실제 구현됨)
public void LogPerformanceStats()
{
var stats = new VavCorePerformanceStats();
vavcore_get_performance_stats(decoderHandle, ref stats);
GD.Print($"Frames decoded: {stats.frames_decoded}");
GD.Print($"Frames dropped: {stats.frames_dropped}");
GD.Print($"Average decode time: {stats.avg_decode_time_ms:F2} ms");
GD.Print($"Memory usage: {stats.memory_usage_bytes / 1024 / 1024} MB");
GD.Print($"GPU acceleration: {stats.gpu_acceleration_enabled}");
}
// ✅ 실제 하드웨어 기능 감지
public void CheckHardwareCapabilities()
{
var caps = new VavCoreHardwareCapabilities();
vavcore_get_hardware_capabilities(ref caps);
GD.Print($"NVDEC available: {caps.nvdec_available}");
GD.Print($"VPL available: {caps.vpl_available}");
GD.Print($"AMF available: {caps.amf_available}");
GD.Print($"Zero-copy decoding: {caps.zero_copy_supported}");
GD.Print($"GPU surface binding: {caps.gpu_surface_supported}");
}
```
### **실제 데모 프로젝트 성능**
-**텍스처 재사용**: 첫 프레임만 생성, 이후 Update로 빠른 처리
-**GPU 메모리 풀링**: Godot 내장 텍스처 시스템 최적 활용
-**메모리 연속성**: YUV 평면 자동 감지 및 최적화
-**실시간 재생**: 최적화된 파이프라인으로 부드러운 비디오 재생
## 🐛 **실제 해결된 문제들 및 트러블슈팅**
### **해결된 주요 문제들**
1. **VavCore DLL 로드 문제 (해결됨)**
```
✅ 해결책: libs/windows-x86_64/ 디렉토리에 VavCore.dll 배치
✅ 검증: CheckVavCoreAvailability() 함수로 DLL 로드 확인
✅ P/Invoke: 28개 vavcore_* 함수 모두 정상 연결
```
2. **3번 메모리 복사 성능 문제 (해결됨)**
```
❌ 문제: CreateSingleBlockYUVTexture()에서 Array.Copy 3번 호출
✅ 해결: 1번의 Buffer.MemoryCopy로 전체 YUV 데이터 복사
✅ 결과: GPU 셰이더에서 오프셋 계산으로 Y/U/V 추출
```
3. **Godot 4.4.1 호환성 문제 (해결됨)**
```
✅ RenderingDevice API 완전 활용
✅ ImageTexture.Update() 최적화
✅ ShaderMaterial 파라미터 전달 완료
✅ Zero-Copy GPU Pipeline 구현
```
### **실제 디버그 정보 및 로깅**
```csharp
// ✅ 실제 구현된 디버그 출력들
public override void _Ready()
{
GD.Print("VavCore Demo: Initializing...");
GD.Print("Checking for VavCore Extension...");
if (CheckVavCoreAvailability())
{
GD.Print("VavCore Extension found and loaded");
LogSystemCapabilities();
}
else
{
GD.PrintErr("VavCore Extension not available");
}
}
// ✅ 시스템 기능 로깅
private void LogSystemCapabilities()
{
GD.Print($"Godot version: {Engine.GetVersionInfo()}");
GD.Print($"Rendering driver: {RenderingServer.Singleton.GetRenderingDriverName()}");
var caps = new VavCoreHardwareCapabilities();
vavcore_get_hardware_capabilities(ref caps);
GD.Print($"Available decoders:");
if (caps.nvdec_available) GD.Print(" - NVDEC (NVIDIA)");
if (caps.vpl_available) GD.Print(" - VPL (Intel)");
if (caps.amf_available) GD.Print(" - AMF (AMD)");
GD.Print(" - dav1d (Software)");
}
// ✅ 비디오 로드 디버그 정보
private void OnLoadButtonPressed()
{
string testVideoPath = "D:/Project/video-av1/sample/simple_test.webm";
GD.Print($"Loading video: {testVideoPath}");
if (player.LoadVideo(testVideoPath))
{
GD.Print("Video loaded successfully");
GetNode<Label>("StatusLabel").Text = "Video loaded";
}
else
{
GD.PrintErr("Failed to load video");
GetNode<Label>("StatusLabel").Text = "Load failed";
}
}
```
## ✅ **완료된 구현 및 향후 계획**
### **현재 완료된 기능들**
1. ✅ **VavCore C API**: 28개 함수 완전 구현, DLL 빌드 성공
2. ✅ **하드웨어 가속**: NVDEC, VPL, AMF, Media Foundation 모든 디코더
3. ✅ **Zero-Copy GPU Pipeline**: 플랫폼별 GPU Surface 직접 바인딩
4. ✅ **CPU Fallback**: 완전한 소프트웨어 렌더링 시스템
5. ✅ **Godot 4.4.1 통합**: RenderingDevice API 완전 활용
6. ✅ **최적화**: 텍스처 캐싱, 단일 블록 복사, 메모리 풀링
7. ✅ **데모 프로젝트**: 완전 동작하는 VavCore Demo 구현
### **향후 확장 계획**
1. **오디오 지원**: VavCore 오디오 디코딩 통합
2. **네트워크 스트리밍**: HTTP/RTMP 스트리밍 지원
3. **모바일 최적화**: Android MediaCodec, iOS VideoToolbox 네이티브 통합
4. **Unity/Unreal 확장**: 다른 게임 엔진용 플러그인
### **실제 사용 가능한 프로젝트**
```bash
# 지금 바로 실행 가능한 데모
cd godot-projects/vavcore-demo/
# Godot 4.4.1에서 열기
# Load Video → Play → 실제 AV1 비디오 재생 확인
```
---
🎮 **Godot 4.4.1용 완전 구현된 크로스 플랫폼 AV1 비디오 디코딩!**
**하드웨어 가속 + 소프트웨어 fallback으로 최대 호환성!**
✅ **Zero-Copy GPU Pipeline + CPU 하이브리드 렌더링 완성!**

View File

@@ -1,84 +0,0 @@
using System;
using VavCore.Wrapper;
// Simple console test to verify VavCore DLL connection
class TestVavCoreDLL
{
static void Main(string[] args)
{
Console.WriteLine("VavCore DLL Connection Test");
Console.WriteLine("===========================");
try
{
// Test VavCore DLL connection
Console.WriteLine("Testing VavCore DLL connection...");
// Get version string
var version = VavCore.GetVersion();
Console.WriteLine($"VavCore version: {version}");
// Initialize VavCore
Console.WriteLine("Initializing VavCore...");
bool initSuccess = VavCore.Initialize();
Console.WriteLine($"VavCore initialization: {(initSuccess ? "SUCCESS" : "FAILED")}");
if (initSuccess)
{
// Test player creation
Console.WriteLine("Creating VavCore player...");
var player = VavCore.CreatePlayer();
Console.WriteLine($"Player creation: {(player != IntPtr.Zero ? "SUCCESS" : "FAILED")}");
if (player != IntPtr.Zero)
{
// Test decoder type setting
Console.WriteLine("Setting decoder type to AUTO...");
bool setDecoderSuccess = VavCore.SetDecoderType(player, DecoderType.AUTO);
Console.WriteLine($"Set decoder type: {(setDecoderSuccess ? "SUCCESS" : "FAILED")}");
// Test surface type support
Console.WriteLine("Checking Vulkan surface support...");
bool vulkanSupported = VavCore.SupportsSurfaceType(SurfaceType.Vulkan);
Console.WriteLine($"Vulkan surface support: {(vulkanSupported ? "SUPPORTED" : "NOT SUPPORTED")}");
Console.WriteLine("Checking D3D11 surface support...");
bool d3d11Supported = VavCore.SupportsSurfaceType(SurfaceType.D3D11);
Console.WriteLine($"D3D11 surface support: {(d3d11Supported ? "SUPPORTED" : "NOT SUPPORTED")}");
// Get optimal surface type
Console.WriteLine("Getting optimal surface type...");
var optimalSurface = VavCore.GetOptimalSurfaceType();
Console.WriteLine($"Optimal surface type: {optimalSurface}");
// Test performance metrics
Console.WriteLine("Getting performance metrics...");
var metrics = VavCore.GetPerformanceMetrics(player);
Console.WriteLine($"Performance metrics - FPS: {metrics.CurrentFPS:F2}, Dropped: {metrics.DroppedFrames}");
// Clean up player
Console.WriteLine("Destroying player...");
VavCore.DestroyPlayer(player);
Console.WriteLine("Player destroyed");
}
// Clean up VavCore
Console.WriteLine("Cleaning up VavCore...");
VavCore.Cleanup();
Console.WriteLine("VavCore cleanup completed");
}
Console.WriteLine("\n=== VavCore DLL Connection Test COMPLETED SUCCESSFULLY ===");
}
catch (Exception ex)
{
Console.WriteLine($"\n=== VavCore DLL Connection Test FAILED ===");
Console.WriteLine($"Error: {ex.Message}");
Console.WriteLine($"Stack trace: {ex.StackTrace}");
return;
}
Console.WriteLine("\nPress any key to exit...");
Console.ReadKey();
}
}

View File

@@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="src\VavCore.Wrapper\VavCore.Wrapper.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,30 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VavCore.Wrapper", "src\VavCore.Wrapper\VavCore.Wrapper.csproj", "{A1B2C3D4-E5F6-7890-ABCD-123456789ABC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VavCore.Godot", "src\VavCore.Godot\VavCore.Godot.csproj", "{B2C3D4E5-F6A7-8901-BCDE-234567890BCD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A1B2C3D4-E5F6-7890-ABCD-123456789ABC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1B2C3D4-E5F6-7890-ABCD-123456789ABC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1B2C3D4-E5F6-7890-ABCD-123456789ABC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1B2C3D4-E5F6-7890-ABCD-123456789ABC}.Release|Any CPU.Build.0 = Release|Any CPU
{B2C3D4E5-F6A7-8901-BCDE-234567890BCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2C3D4E5-F6A7-8901-BCDE-234567890BCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2C3D4E5-F6A7-8901-BCDE-234567890BCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2C3D4E5-F6A7-8901-BCDE-234567890BCD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C3D4E5F6-A7B8-9012-CDEF-345678901CDE}
EndGlobalSection
EndGlobal

View File

@@ -1,23 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<!-- VavCore.Wrapper Reference -->
<ItemGroup>
<Reference Include="VavCore.Wrapper">
<HintPath>src\VavCore.Wrapper\bin\Debug\net6.0\VavCore.Wrapper.dll</HintPath>
</Reference>
</ItemGroup>
<!-- Copy VavCore-debug.dll to output directory -->
<ItemGroup>
<None Include="libs\windows-x86_64\*" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
</ItemGroup>
</Project>

View File

@@ -1,58 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Assembly Info -->
<AssemblyTitle>VavCore Godot Extension</AssemblyTitle>
<AssemblyDescription>High-level Godot 4.x extension for VavCore AV1 decoder with managed nodes and resources</AssemblyDescription>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Company>VavCore Team</Company>
<Product>VavCore Godot Extension</Product>
<Copyright>Copyright © 2024 VavCore Team</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>DEBUG;TRACE;GODOT</DefineConstants>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE;GODOT</DefineConstants>
<Optimize>true</Optimize>
<DebugType>portable</DebugType>
</PropertyGroup>
<!-- Godot 4.x Dependencies -->
<ItemGroup>
<PackageReference Include="Godot.SourceGenerators" Version="4.3.0" />
<PackageReference Include="GodotSharp" Version="4.3.0" />
</ItemGroup>
<!-- VavCore.Wrapper Dependency -->
<ItemGroup>
<ProjectReference Include="..\VavCore.Wrapper\VavCore.Wrapper.csproj" />
</ItemGroup>
<!-- Platform-specific library paths (inherited from VavCore.Wrapper) -->
<ItemGroup>
<None Include="..\..\libs\windows-x86_64\*" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
<None Include="..\..\libs\linux-x86_64\*" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
<None Include="..\..\libs\osx-x86_64\*" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
</ItemGroup>
<!-- Source files are automatically included by .NET SDK -->
<!-- Documentation -->
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\VavCore.Godot.xml</DocumentationFile>
</PropertyGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@@ -1,47 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>11</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Assembly Info -->
<AssemblyTitle>VavCore P/Invoke Wrapper</AssemblyTitle>
<AssemblyDescription>Low-level P/Invoke wrapper for VavCore AV1 decoder library</AssemblyDescription>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Company>VavCore Team</Company>
<Product>VavCore Godot Extension</Product>
<Copyright>Copyright © 2024 VavCore Team</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>portable</DebugType>
</PropertyGroup>
<!-- Platform-specific library paths -->
<ItemGroup>
<None Include="..\..\libs\windows-x86_64\*" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOSPlatform('Windows'))" />
<None Include="..\..\libs\linux-x86_64\*" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
<None Include="..\..\libs\osx-x86_64\*" CopyToOutputDirectory="PreserveNewest" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
</ItemGroup>
<!-- Source files are automatically included by .NET SDK -->
<!-- Documentation -->
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\VavCore.Wrapper.xml</DocumentationFile>
</PropertyGroup>
</Project>

View File

@@ -1,262 +0,0 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace VavCore.Wrapper;
/// <summary>
/// Simple VavCore video decoder - all-in-one class
/// Direct P/Invoke wrapper for VavCore C API with minimal overhead
/// </summary>
public class VavCore : IDisposable
{
// ================================================
// Essential Data Types
// ================================================
public enum DecoderType : int
{
Auto = 0, DAV1D = 1, NVDEC = 2, MediaFoundation = 3,
VPL = 4, AMF = 5, MediaCodec = 6
}
public enum QualityMode : int
{
Conservative = 0, Fast = 1, UltraFast = 2
}
public enum SurfaceType : int
{
CPU = 0, D3D11Texture = 1, D3D12Resource = 2, VulkanImage = 7,
OpenGLTexture = 9, MetalTexture = 10, OpenGLESTexture = 6
}
[StructLayout(LayoutKind.Sequential)]
public struct VideoFrame
{
public IntPtr YPlane, UPlane, VPlane;
public int YStride, UStride, VStride;
public int Width, Height;
public ulong TimestampUs, FrameNumber;
// User-friendly properties
public ulong FrameIndex => FrameNumber;
public double TimestampSeconds => TimestampUs / 1_000_000.0;
}
[StructLayout(LayoutKind.Sequential)]
public struct VideoMetadata
{
public int Width, Height;
public double FrameRate, DurationSeconds;
public ulong TotalFrames;
public IntPtr CodecName;
}
[StructLayout(LayoutKind.Sequential)]
public struct PerformanceMetrics
{
public double AverageDecodeTimeMs, CurrentFps;
public ulong FramesDecoded, FramesDropped;
public int CurrentQualityLevel;
}
[StructLayout(LayoutKind.Sequential)]
public struct VideoFrameSurface
{
public SurfaceType SurfaceType;
public IntPtr YSurface, UVSurface; // GPU surface handles
public int Width, Height;
public ulong TimestampUs, FrameNumber;
// User-friendly properties
public ulong FrameIndex => FrameNumber;
public double TimestampSeconds => TimestampUs / 1_000_000.0;
}
// ================================================
// P/Invoke (Essential C API functions only)
// ================================================
private const string DllName = "VavCore-debug";
[DllImport(DllName)] private static extern int vavcore_initialize();
[DllImport(DllName)] private static extern void vavcore_cleanup();
[DllImport(DllName)] private static extern IntPtr vavcore_create_player();
[DllImport(DllName)] private static extern void vavcore_destroy_player(IntPtr player);
[DllImport(DllName)] private static extern int vavcore_open_file(IntPtr player, string filePath);
[DllImport(DllName)] private static extern int vavcore_close_file(IntPtr player);
[DllImport(DllName)] private static extern int vavcore_decode_next_frame(IntPtr player, ref VideoFrame frame);
[DllImport(DllName)] private static extern int vavcore_get_metadata(IntPtr player, ref VideoMetadata metadata);
[DllImport(DllName)] private static extern int vavcore_seek_to_time(IntPtr player, double timeSeconds);
[DllImport(DllName)] private static extern int vavcore_seek_to_frame(IntPtr player, ulong frameNumber);
[DllImport(DllName)] private static extern int vavcore_reset(IntPtr player);
[DllImport(DllName)] private static extern int vavcore_is_open(IntPtr player);
[DllImport(DllName)] private static extern int vavcore_is_end_of_file(IntPtr player);
[DllImport(DllName)] private static extern int vavcore_set_decoder_type(IntPtr player, DecoderType decoderType);
[DllImport(DllName)] private static extern int vavcore_set_quality_mode(IntPtr player, QualityMode qualityMode);
[DllImport(DllName)] private static extern int vavcore_get_performance_metrics(IntPtr player, ref PerformanceMetrics metrics);
[DllImport(DllName)] private static extern int vavcore_decode_to_surface(IntPtr player, SurfaceType targetType, IntPtr targetSurface, ref VideoFrameSurface frame);
// ================================================
// Simple Public API
// ================================================
private IntPtr _player = IntPtr.Zero;
private bool _disposed = false;
private static bool _initialized = false;
public bool IsOpen => _player != IntPtr.Zero && vavcore_is_open(_player) != 0;
public bool IsEndOfFile => _player != IntPtr.Zero && vavcore_is_end_of_file(_player) != 0;
public VavCore()
{
if (!_initialized)
{
if (vavcore_initialize() != 0)
throw new InvalidOperationException("Failed to initialize VavCore");
_initialized = true;
}
_player = vavcore_create_player();
if (_player == IntPtr.Zero)
throw new InvalidOperationException("Failed to create VavCore player");
}
public bool OpenFile(string filePath)
{
return vavcore_open_file(_player, filePath) == 0;
}
public void CloseFile()
{
if (IsOpen) vavcore_close_file(_player);
}
public bool DecodeNextFrame(out VideoFrame frame)
{
frame = new VideoFrame();
return vavcore_decode_next_frame(_player, ref frame) == 0;
}
public bool GetMetadata(out VideoMetadata metadata)
{
metadata = new VideoMetadata();
return vavcore_get_metadata(_player, ref metadata) == 0;
}
public bool SeekToTime(double timeSeconds)
{
return vavcore_seek_to_time(_player, timeSeconds) == 0;
}
public bool SeekToFrame(ulong frameNumber)
{
return vavcore_seek_to_frame(_player, frameNumber) == 0;
}
public bool Reset()
{
return vavcore_reset(_player) == 0;
}
public bool SetDecoderType(DecoderType decoderType)
{
return vavcore_set_decoder_type(_player, decoderType) == 0;
}
public bool SetQualityMode(QualityMode qualityMode)
{
return vavcore_set_quality_mode(_player, qualityMode) == 0;
}
public bool GetPerformanceMetrics(out PerformanceMetrics metrics)
{
metrics = new PerformanceMetrics();
return vavcore_get_performance_metrics(_player, ref metrics) == 0;
}
// ================================================
// GPU Surface Decoding (Primary method)
// ================================================
public bool DecodeToSurface(SurfaceType surfaceType, IntPtr targetSurface, out VideoFrameSurface frame)
{
frame = new VideoFrameSurface();
return vavcore_decode_to_surface(_player, surfaceType, targetSurface, ref frame) == 0;
}
// ================================================
// User-friendly helpers
// ================================================
public Dictionary<string, object> GetVideoInfo()
{
var info = new Dictionary<string, object>();
if (GetMetadata(out var meta))
{
info["width"] = meta.Width;
info["height"] = meta.Height;
info["duration"] = meta.DurationSeconds;
info["frames"] = (long)meta.TotalFrames;
info["fps"] = meta.FrameRate;
}
return info;
}
public Dictionary<string, object> GetStats()
{
var stats = new Dictionary<string, object>();
if (GetPerformanceMetrics(out var metrics))
{
stats["frames_decoded"] = (long)metrics.FramesDecoded;
stats["frames_dropped"] = (long)metrics.FramesDropped;
stats["avg_decode_time_ms"] = metrics.AverageDecodeTimeMs;
stats["current_fps"] = metrics.CurrentFps;
}
return stats;
}
// ================================================
// Static Utilities
// ================================================
public static bool Initialize()
{
if (!_initialized)
{
_initialized = vavcore_initialize() == 0;
}
return _initialized;
}
public static string GetVersion() => "1.0.0";
public static DecoderType GetOptimalDecoderType()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return DecoderType.Auto; // NVDEC/VPL/AMF
else
return DecoderType.DAV1D; // Fallback for Linux/macOS/Android
}
// ================================================
// Disposal
// ================================================
public void Dispose()
{
if (!_disposed)
{
CloseFile();
if (_player != IntPtr.Zero)
{
vavcore_destroy_player(_player);
_player = IntPtr.Zero;
}
_disposed = true;
}
}
~VavCore() => Dispose();
}

View File

@@ -1,15 +1,15 @@
# VavCore Godot 4.x Extension
# VavCore Godot 4.x Extension - Windows Platform
Cross-platform C# extension for hardware-accelerated AV1 video decoding in Godot 4.x using VavCore library.
Windows-specific C# extension for hardware-accelerated AV1 video decoding in Godot 4.x using VavCore library.
## 🎯 **Features**
### **🚀 Hardware-Accelerated AV1 Decoding**
- **Windows**: NVIDIA NVDEC, Intel VPL, AMD AMF, Media Foundation
- **Linux**: NVIDIA NVDEC, Intel VPL, AMD AMF, dav1d fallback
- **macOS**: VideoToolbox, dav1d fallback
- **Android**: MediaCodec, dav1d fallback (via Android plugin)
- **iOS**: VideoToolbox, dav1d fallback
### **🚀 Windows Hardware-Accelerated AV1 Decoding**
- **NVIDIA NVDEC**: RTX 30/40 series GPU acceleration
- **Intel VPL**: 11th gen+ CPU with Intel Xe graphics
- **AMD AMF**: RX 6000/7000 series GPU acceleration
- **Media Foundation**: Windows 10/11 built-in decoder
- **dav1d fallback**: Software decoding for all systems
### **🎮 Godot 4.x Integration**
- **High-level Nodes**: Easy-to-use video player components
@@ -17,16 +17,17 @@ Cross-platform C# extension for hardware-accelerated AV1 video decoding in Godot
- **Resource System**: Godot-native video file and settings resources
- **Editor Integration**: Asset importers, custom inspectors, dock widgets
### **🔧 Cross-Platform Architecture**
- **VavCore.Wrapper**: P/Invoke layer for C API access
### **🔧 Windows Platform Architecture**
- **VavCore.Wrapper**: P/Invoke layer for Windows VavCore DLL
- **VavCore.Godot**: Godot-specific nodes and utilities
- **Platform Plugins**: Native Android/iOS integration when needed
- **Windows Libraries**: NVDEC, VPL, AMF native integration
## 📁 **Project Structure**
```
vav2/godot_extension/
vav2/platforms/windows/godot-plugin/
├── VavCoreGodot.sln # Visual Studio solution
├── build.bat # Windows build script
├── src/
│ ├── VavCore.Wrapper/ # P/Invoke wrapper library
│ │ ├── VavCore.Wrapper.csproj # .NET 6.0 library project
@@ -48,10 +49,13 @@ vav2/godot_extension/
│ └── Plugin/ # Editor integration
│ └── VavCorePlugin.cs # Editor plugin and importers
├── libs/ # Native library binaries
── windows-x86_64/ # Windows VavCore.dll
├── linux-x86_64/ # Linux libVavCore.so
└── osx-x86_64/ # macOS libVavCore.dylib
── README.md # This file
── windows-x86_64/ # Windows-specific libraries
├── VavCore.dll # Release VavCore library
└── VavCore-debug.dll # Debug VavCore library
── addons/ # Godot addon structure
├── bin/ # Build output
├── obj/ # Intermediate files
└── README.md # This file
```
## 🚀 **Getting Started**
@@ -67,8 +71,8 @@ vav2/godot_extension/
### **2. Building the Extension**
```bash
# Clone or navigate to the extension directory
cd vav2/godot_extension/
# Navigate to the Windows godot-plugin directory
cd vav2/platforms/windows/godot-plugin/
# Restore NuGet packages
dotnet restore
@@ -87,7 +91,7 @@ dotnet build src/VavCore.Godot/VavCore.Godot.csproj --configuration Release
```xml
<!-- In your Godot project's .csproj file -->
<ItemGroup>
<ProjectReference Include="path/to/vav2/godot_extension/src/VavCore.Godot/VavCore.Godot.csproj" />
<ProjectReference Include="vav2/platforms/windows/godot-plugin/src/VavCore.Godot/VavCore.Godot.csproj" />
</ItemGroup>
```
@@ -97,10 +101,15 @@ dotnet build src/VavCore.Godot/VavCore.Godot.csproj --configuration Release
cp src/VavCore.Wrapper/bin/Release/net6.0/VavCore.Wrapper.dll /path/to/godot/project/
cp src/VavCore.Godot/bin/Release/net6.0/VavCore.Godot.dll /path/to/godot/project/
# Copy native libraries
cp libs/windows-x86_64/* /path/to/godot/project/ # Windows
cp libs/linux-x86_64/* /path/to/godot/project/ # Linux
cp libs/osx-x86_64/* /path/to/godot/project/ # macOS
# Copy Windows native libraries
cp libs/windows-x86_64/VavCore.dll /path/to/godot/project/
```
#### **Option C: Use Demo Project**
```bash
# Use the complete demo project
cd godot-projects/vavcore-demo/
# Open in Godot 4.4.1 - already configured with VavCore extension
```
## 🎮 **Usage Examples**