SHA256
Fix Color Space Issue
This commit is contained in:
4 files changed
+73
-55
No files matched your search
@@ -158,6 +158,9 @@ namespace ADOFAIRenderer.Util.FFmpeg
|
||||
/// </summary>
|
||||
private AVPixelFormat _dstPixFmt = AVPixelFormat.AV_PIX_FMT_YUV420P;
|
||||
|
||||
/// <summary>최종 선택되어 구동된 인코더의 픽셀 포맷입니다.</summary>
|
||||
public AVPixelFormat SelectedPixelFormat => _dstPixFmt;
|
||||
|
||||
/// <summary>
|
||||
/// 인코딩된 패킷 데이터를 임시로 담을 패킷 구조체.
|
||||
/// 매 프레임마다 할당/해제하는 오버헤드를 방지하기 위해 멤버 변수로 캐싱합니다.
|
||||
|
||||
+6
-22
@@ -3,7 +3,6 @@ using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ADOFAIRenderer.Core;
|
||||
using ADOFAIRenderer.Util.FFmpeg;
|
||||
using FFmpeg.AutoGen;
|
||||
using MelonLoader;
|
||||
using Unity.Collections;
|
||||
@@ -27,8 +26,11 @@ namespace ADOFAIRenderer.Util
|
||||
private bool _isInitialized;
|
||||
private volatile bool _isDisposed;
|
||||
|
||||
public FrameReader()
|
||||
private readonly AVPixelFormat _targetFormat;
|
||||
|
||||
public FrameReader(AVPixelFormat targetFormat)
|
||||
{
|
||||
_targetFormat = targetFormat;
|
||||
InitializePool();
|
||||
}
|
||||
|
||||
@@ -48,24 +50,6 @@ namespace ADOFAIRenderer.Util
|
||||
}
|
||||
}
|
||||
|
||||
private static unsafe AVPixelFormat PredictPixelFormat(Codec codec)
|
||||
{
|
||||
var candidates = GPUUtil.GetPrioritizedEncoderCandidates(codec);
|
||||
// ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
|
||||
foreach (var encoderName in candidates)
|
||||
{
|
||||
var pCodec = ffmpeg.avcodec_find_encoder_by_name(encoderName);
|
||||
if (pCodec == null) continue;
|
||||
|
||||
if (encoderName.Contains("qsv") || encoderName.Contains("nvenc") || encoderName.Contains("amf"))
|
||||
{
|
||||
return AVPixelFormat.AV_PIX_FMT_NV12;
|
||||
}
|
||||
return encoderName == "libvvenc" ? AVPixelFormat.AV_PIX_FMT_YUV420P10LE : AVPixelFormat.AV_PIX_FMT_YUV420P;
|
||||
}
|
||||
return AVPixelFormat.AV_PIX_FMT_YUV420P;
|
||||
}
|
||||
|
||||
public void RequestFrameCapture(Texture texture, long currentFrame)
|
||||
{
|
||||
if (!RenderManager.IsCapturingActive) return;
|
||||
@@ -90,9 +74,9 @@ namespace ADOFAIRenderer.Util
|
||||
bool useGPUConversion = RenderMod.ColorConversionShader;
|
||||
AVPixelFormat expectedFmt = AVPixelFormat.AV_PIX_FMT_RGBA;
|
||||
|
||||
if (useGPUConversion && RenderManager.Instance)
|
||||
if (useGPUConversion)
|
||||
{
|
||||
expectedFmt = PredictPixelFormat(RenderManager.Instance.Configuration.Codec);
|
||||
expectedFmt = _targetFormat;
|
||||
// Compute Shader는 NV12와 YUV420P만 지원하므로 그 외 포맷은 CPU 폴백 처리
|
||||
if (expectedFmt != AVPixelFormat.AV_PIX_FMT_NV12 && expectedFmt != AVPixelFormat.AV_PIX_FMT_YUV420P)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user