Do naming refactoring on Ryujinx.Graphics (#611)

* Renaming part 1

* Renaming part 2

* Renaming part 3

* Renaming part 4

* Renaming part 5

* Renaming part 6

* Renaming part 7

* Renaming part 8

* Renaming part 9

* Renaming part 10

* General cleanup

* Thought I got all of these

* Apply #595

* Additional renaming

* Tweaks from feedback

* Rename files
This commit is contained in:
Alex Barney 2019-03-03 19:45:25 -06:00 committed by jduncanator
parent 8e71ea0812
commit 1f554c1093
125 changed files with 9121 additions and 9120 deletions

View file

@ -9,124 +9,124 @@ namespace Ryujinx.Graphics.VDec
{
unsafe class VideoDecoder
{
private NvGpu Gpu;
private NvGpu _gpu;
private H264Decoder H264Decoder;
private Vp9Decoder Vp9Decoder;
private H264Decoder _h264Decoder;
private Vp9Decoder _vp9Decoder;
private VideoCodec CurrentVideoCodec;
private VideoCodec _currentVideoCodec;
private long DecoderContextAddress;
private long FrameDataAddress;
private long VpxCurrLumaAddress;
private long VpxRef0LumaAddress;
private long VpxRef1LumaAddress;
private long VpxRef2LumaAddress;
private long VpxCurrChromaAddress;
private long VpxRef0ChromaAddress;
private long VpxRef1ChromaAddress;
private long VpxRef2ChromaAddress;
private long VpxProbTablesAddress;
private long _decoderContextAddress;
private long _frameDataAddress;
private long _vpxCurrLumaAddress;
private long _vpxRef0LumaAddress;
private long _vpxRef1LumaAddress;
private long _vpxRef2LumaAddress;
private long _vpxCurrChromaAddress;
private long _vpxRef0ChromaAddress;
private long _vpxRef1ChromaAddress;
private long _vpxRef2ChromaAddress;
private long _vpxProbTablesAddress;
public VideoDecoder(NvGpu Gpu)
public VideoDecoder(NvGpu gpu)
{
this.Gpu = Gpu;
_gpu = gpu;
H264Decoder = new H264Decoder();
Vp9Decoder = new Vp9Decoder();
_h264Decoder = new H264Decoder();
_vp9Decoder = new Vp9Decoder();
}
public void Process(NvGpuVmm Vmm, int MethodOffset, int[] Arguments)
public void Process(NvGpuVmm vmm, int methodOffset, int[] arguments)
{
VideoDecoderMeth Method = (VideoDecoderMeth)MethodOffset;
VideoDecoderMeth method = (VideoDecoderMeth)methodOffset;
switch (Method)
switch (method)
{
case VideoDecoderMeth.SetVideoCodec: SetVideoCodec (Vmm, Arguments); break;
case VideoDecoderMeth.Execute: Execute (Vmm, Arguments); break;
case VideoDecoderMeth.SetDecoderCtxAddr: SetDecoderCtxAddr (Vmm, Arguments); break;
case VideoDecoderMeth.SetFrameDataAddr: SetFrameDataAddr (Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxCurrLumaAddr: SetVpxCurrLumaAddr (Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxRef0LumaAddr: SetVpxRef0LumaAddr (Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxRef1LumaAddr: SetVpxRef1LumaAddr (Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxRef2LumaAddr: SetVpxRef2LumaAddr (Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxCurrChromaAddr: SetVpxCurrChromaAddr(Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxRef0ChromaAddr: SetVpxRef0ChromaAddr(Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxRef1ChromaAddr: SetVpxRef1ChromaAddr(Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxRef2ChromaAddr: SetVpxRef2ChromaAddr(Vmm, Arguments); break;
case VideoDecoderMeth.SetVpxProbTablesAddr: SetVpxProbTablesAddr(Vmm, Arguments); break;
case VideoDecoderMeth.SetVideoCodec: SetVideoCodec (vmm, arguments); break;
case VideoDecoderMeth.Execute: Execute (vmm, arguments); break;
case VideoDecoderMeth.SetDecoderCtxAddr: SetDecoderCtxAddr (vmm, arguments); break;
case VideoDecoderMeth.SetFrameDataAddr: SetFrameDataAddr (vmm, arguments); break;
case VideoDecoderMeth.SetVpxCurrLumaAddr: SetVpxCurrLumaAddr (vmm, arguments); break;
case VideoDecoderMeth.SetVpxRef0LumaAddr: SetVpxRef0LumaAddr (vmm, arguments); break;
case VideoDecoderMeth.SetVpxRef1LumaAddr: SetVpxRef1LumaAddr (vmm, arguments); break;
case VideoDecoderMeth.SetVpxRef2LumaAddr: SetVpxRef2LumaAddr (vmm, arguments); break;
case VideoDecoderMeth.SetVpxCurrChromaAddr: SetVpxCurrChromaAddr(vmm, arguments); break;
case VideoDecoderMeth.SetVpxRef0ChromaAddr: SetVpxRef0ChromaAddr(vmm, arguments); break;
case VideoDecoderMeth.SetVpxRef1ChromaAddr: SetVpxRef1ChromaAddr(vmm, arguments); break;
case VideoDecoderMeth.SetVpxRef2ChromaAddr: SetVpxRef2ChromaAddr(vmm, arguments); break;
case VideoDecoderMeth.SetVpxProbTablesAddr: SetVpxProbTablesAddr(vmm, arguments); break;
}
}
private void SetVideoCodec(NvGpuVmm Vmm, int[] Arguments)
private void SetVideoCodec(NvGpuVmm vmm, int[] arguments)
{
CurrentVideoCodec = (VideoCodec)Arguments[0];
_currentVideoCodec = (VideoCodec)arguments[0];
}
private void Execute(NvGpuVmm Vmm, int[] Arguments)
private void Execute(NvGpuVmm vmm, int[] arguments)
{
if (CurrentVideoCodec == VideoCodec.H264)
if (_currentVideoCodec == VideoCodec.H264)
{
int FrameDataSize = Vmm.ReadInt32(DecoderContextAddress + 0x48);
int frameDataSize = vmm.ReadInt32(_decoderContextAddress + 0x48);
H264ParameterSets Params = MemoryHelper.Read<H264ParameterSets>(Vmm.Memory, Vmm.GetPhysicalAddress(DecoderContextAddress + 0x58));
H264ParameterSets Params = MemoryHelper.Read<H264ParameterSets>(vmm.Memory, vmm.GetPhysicalAddress(_decoderContextAddress + 0x58));
H264Matrices Matrices = new H264Matrices()
H264Matrices matrices = new H264Matrices()
{
ScalingMatrix4 = Vmm.ReadBytes(DecoderContextAddress + 0x1c0, 6 * 16),
ScalingMatrix8 = Vmm.ReadBytes(DecoderContextAddress + 0x220, 2 * 64)
ScalingMatrix4 = vmm.ReadBytes(_decoderContextAddress + 0x1c0, 6 * 16),
ScalingMatrix8 = vmm.ReadBytes(_decoderContextAddress + 0x220, 2 * 64)
};
byte[] FrameData = Vmm.ReadBytes(FrameDataAddress, FrameDataSize);
byte[] frameData = vmm.ReadBytes(_frameDataAddress, frameDataSize);
H264Decoder.Decode(Params, Matrices, FrameData);
_h264Decoder.Decode(Params, matrices, frameData);
}
else if (CurrentVideoCodec == VideoCodec.Vp9)
else if (_currentVideoCodec == VideoCodec.Vp9)
{
int FrameDataSize = Vmm.ReadInt32(DecoderContextAddress + 0x30);
int frameDataSize = vmm.ReadInt32(_decoderContextAddress + 0x30);
Vp9FrameKeys Keys = new Vp9FrameKeys()
Vp9FrameKeys keys = new Vp9FrameKeys()
{
CurrKey = Vmm.GetPhysicalAddress(VpxCurrLumaAddress),
Ref0Key = Vmm.GetPhysicalAddress(VpxRef0LumaAddress),
Ref1Key = Vmm.GetPhysicalAddress(VpxRef1LumaAddress),
Ref2Key = Vmm.GetPhysicalAddress(VpxRef2LumaAddress)
CurrKey = vmm.GetPhysicalAddress(_vpxCurrLumaAddress),
Ref0Key = vmm.GetPhysicalAddress(_vpxRef0LumaAddress),
Ref1Key = vmm.GetPhysicalAddress(_vpxRef1LumaAddress),
Ref2Key = vmm.GetPhysicalAddress(_vpxRef2LumaAddress)
};
Vp9FrameHeader Header = MemoryHelper.Read<Vp9FrameHeader>(Vmm.Memory, Vmm.GetPhysicalAddress(DecoderContextAddress + 0x48));
Vp9FrameHeader header = MemoryHelper.Read<Vp9FrameHeader>(vmm.Memory, vmm.GetPhysicalAddress(_decoderContextAddress + 0x48));
Vp9ProbabilityTables Probs = new Vp9ProbabilityTables()
Vp9ProbabilityTables probs = new Vp9ProbabilityTables()
{
SegmentationTreeProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x387, 0x7),
SegmentationPredProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x38e, 0x3),
Tx8x8Probs = Vmm.ReadBytes(VpxProbTablesAddress + 0x470, 0x2),
Tx16x16Probs = Vmm.ReadBytes(VpxProbTablesAddress + 0x472, 0x4),
Tx32x32Probs = Vmm.ReadBytes(VpxProbTablesAddress + 0x476, 0x6),
CoefProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x5a0, 0x900),
SkipProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x537, 0x3),
InterModeProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x400, 0x1c),
InterpFilterProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x52a, 0x8),
IsInterProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x41c, 0x4),
CompModeProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x532, 0x5),
SingleRefProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x580, 0xa),
CompRefProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x58a, 0x5),
YModeProbs0 = Vmm.ReadBytes(VpxProbTablesAddress + 0x480, 0x20),
YModeProbs1 = Vmm.ReadBytes(VpxProbTablesAddress + 0x47c, 0x4),
PartitionProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x4e0, 0x40),
MvJointProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x53b, 0x3),
MvSignProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x53e, 0x3),
MvClassProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x54c, 0x14),
MvClass0BitProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x540, 0x3),
MvBitsProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x56c, 0x14),
MvClass0FrProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x560, 0xc),
MvFrProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x542, 0x6),
MvClass0HpProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x548, 0x2),
MvHpProbs = Vmm.ReadBytes(VpxProbTablesAddress + 0x54a, 0x2)
SegmentationTreeProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x387, 0x7),
SegmentationPredProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x38e, 0x3),
Tx8x8Probs = vmm.ReadBytes(_vpxProbTablesAddress + 0x470, 0x2),
Tx16x16Probs = vmm.ReadBytes(_vpxProbTablesAddress + 0x472, 0x4),
Tx32x32Probs = vmm.ReadBytes(_vpxProbTablesAddress + 0x476, 0x6),
CoefProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x5a0, 0x900),
SkipProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x537, 0x3),
InterModeProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x400, 0x1c),
InterpFilterProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x52a, 0x8),
IsInterProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x41c, 0x4),
CompModeProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x532, 0x5),
SingleRefProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x580, 0xa),
CompRefProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x58a, 0x5),
YModeProbs0 = vmm.ReadBytes(_vpxProbTablesAddress + 0x480, 0x20),
YModeProbs1 = vmm.ReadBytes(_vpxProbTablesAddress + 0x47c, 0x4),
PartitionProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x4e0, 0x40),
MvJointProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x53b, 0x3),
MvSignProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x53e, 0x3),
MvClassProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x54c, 0x14),
MvClass0BitProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x540, 0x3),
MvBitsProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x56c, 0x14),
MvClass0FrProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x560, 0xc),
MvFrProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x542, 0x6),
MvClass0HpProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x548, 0x2),
MvHpProbs = vmm.ReadBytes(_vpxProbTablesAddress + 0x54a, 0x2)
};
byte[] FrameData = Vmm.ReadBytes(FrameDataAddress, FrameDataSize);
byte[] frameData = vmm.ReadBytes(_frameDataAddress, frameDataSize);
Vp9Decoder.Decode(Keys, Header, Probs, FrameData);
_vp9Decoder.Decode(keys, header, probs, frameData);
}
else
{
@ -134,148 +134,148 @@ namespace Ryujinx.Graphics.VDec
}
}
private void SetDecoderCtxAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetDecoderCtxAddr(NvGpuVmm vmm, int[] arguments)
{
DecoderContextAddress = GetAddress(Arguments);
_decoderContextAddress = GetAddress(arguments);
}
private void SetFrameDataAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetFrameDataAddr(NvGpuVmm vmm, int[] arguments)
{
FrameDataAddress = GetAddress(Arguments);
_frameDataAddress = GetAddress(arguments);
}
private void SetVpxCurrLumaAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxCurrLumaAddr(NvGpuVmm vmm, int[] arguments)
{
VpxCurrLumaAddress = GetAddress(Arguments);
_vpxCurrLumaAddress = GetAddress(arguments);
}
private void SetVpxRef0LumaAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxRef0LumaAddr(NvGpuVmm vmm, int[] arguments)
{
VpxRef0LumaAddress = GetAddress(Arguments);
_vpxRef0LumaAddress = GetAddress(arguments);
}
private void SetVpxRef1LumaAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxRef1LumaAddr(NvGpuVmm vmm, int[] arguments)
{
VpxRef1LumaAddress = GetAddress(Arguments);
_vpxRef1LumaAddress = GetAddress(arguments);
}
private void SetVpxRef2LumaAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxRef2LumaAddr(NvGpuVmm vmm, int[] arguments)
{
VpxRef2LumaAddress = GetAddress(Arguments);
_vpxRef2LumaAddress = GetAddress(arguments);
}
private void SetVpxCurrChromaAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxCurrChromaAddr(NvGpuVmm vmm, int[] arguments)
{
VpxCurrChromaAddress = GetAddress(Arguments);
_vpxCurrChromaAddress = GetAddress(arguments);
}
private void SetVpxRef0ChromaAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxRef0ChromaAddr(NvGpuVmm vmm, int[] arguments)
{
VpxRef0ChromaAddress = GetAddress(Arguments);
_vpxRef0ChromaAddress = GetAddress(arguments);
}
private void SetVpxRef1ChromaAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxRef1ChromaAddr(NvGpuVmm vmm, int[] arguments)
{
VpxRef1ChromaAddress = GetAddress(Arguments);
_vpxRef1ChromaAddress = GetAddress(arguments);
}
private void SetVpxRef2ChromaAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxRef2ChromaAddr(NvGpuVmm vmm, int[] arguments)
{
VpxRef2ChromaAddress = GetAddress(Arguments);
_vpxRef2ChromaAddress = GetAddress(arguments);
}
private void SetVpxProbTablesAddr(NvGpuVmm Vmm, int[] Arguments)
private void SetVpxProbTablesAddr(NvGpuVmm vmm, int[] arguments)
{
VpxProbTablesAddress = GetAddress(Arguments);
_vpxProbTablesAddress = GetAddress(arguments);
}
private static long GetAddress(int[] Arguments)
private static long GetAddress(int[] arguments)
{
return (long)(uint)Arguments[0] << 8;
return (long)(uint)arguments[0] << 8;
}
internal void CopyPlanes(NvGpuVmm Vmm, SurfaceOutputConfig OutputConfig)
internal void CopyPlanes(NvGpuVmm vmm, SurfaceOutputConfig outputConfig)
{
switch (OutputConfig.PixelFormat)
switch (outputConfig.PixelFormat)
{
case SurfacePixelFormat.RGBA8: CopyPlanesRgba8 (Vmm, OutputConfig); break;
case SurfacePixelFormat.YUV420P: CopyPlanesYuv420p(Vmm, OutputConfig); break;
case SurfacePixelFormat.Rgba8: CopyPlanesRgba8 (vmm, outputConfig); break;
case SurfacePixelFormat.Yuv420P: CopyPlanesYuv420P(vmm, outputConfig); break;
default: ThrowUnimplementedPixelFormat(OutputConfig.PixelFormat); break;
default: ThrowUnimplementedPixelFormat(outputConfig.PixelFormat); break;
}
}
private void CopyPlanesRgba8(NvGpuVmm Vmm, SurfaceOutputConfig OutputConfig)
private void CopyPlanesRgba8(NvGpuVmm vmm, SurfaceOutputConfig outputConfig)
{
FFmpegFrame Frame = FFmpegWrapper.GetFrameRgba();
FFmpegFrame frame = FFmpegWrapper.GetFrameRgba();
if ((Frame.Width | Frame.Height) == 0)
if ((frame.Width | frame.Height) == 0)
{
return;
}
GalImage Image = new GalImage(
OutputConfig.SurfaceWidth,
OutputConfig.SurfaceHeight, 1, 1, 1,
OutputConfig.GobBlockHeight, 1,
GalImage image = new GalImage(
outputConfig.SurfaceWidth,
outputConfig.SurfaceHeight, 1, 1, 1,
outputConfig.GobBlockHeight, 1,
GalMemoryLayout.BlockLinear,
GalImageFormat.RGBA8 | GalImageFormat.Unorm,
GalImageFormat.Rgba8 | GalImageFormat.Unorm,
GalTextureTarget.TwoD);
ImageUtils.WriteTexture(Vmm, Image, Vmm.GetPhysicalAddress(OutputConfig.SurfaceLumaAddress), Frame.Data);
ImageUtils.WriteTexture(vmm, image, vmm.GetPhysicalAddress(outputConfig.SurfaceLumaAddress), frame.Data);
}
private void CopyPlanesYuv420p(NvGpuVmm Vmm, SurfaceOutputConfig OutputConfig)
private void CopyPlanesYuv420P(NvGpuVmm vmm, SurfaceOutputConfig outputConfig)
{
FFmpegFrame Frame = FFmpegWrapper.GetFrame();
FFmpegFrame frame = FFmpegWrapper.GetFrame();
if ((Frame.Width | Frame.Height) == 0)
if ((frame.Width | frame.Height) == 0)
{
return;
}
int HalfSrcWidth = Frame.Width / 2;
int halfSrcWidth = frame.Width / 2;
int HalfWidth = Frame.Width / 2;
int HalfHeight = Frame.Height / 2;
int halfWidth = frame.Width / 2;
int halfHeight = frame.Height / 2;
int AlignedWidth = (OutputConfig.SurfaceWidth + 0xff) & ~0xff;
int alignedWidth = (outputConfig.SurfaceWidth + 0xff) & ~0xff;
for (int Y = 0; Y < Frame.Height; Y++)
for (int y = 0; y < frame.Height; y++)
{
int Src = Y * Frame.Width;
int Dst = Y * AlignedWidth;
int src = y * frame.Width;
int dst = y * alignedWidth;
int Size = Frame.Width;
int size = frame.Width;
for (int Offset = 0; Offset < Size; Offset++)
for (int offset = 0; offset < size; offset++)
{
Vmm.WriteByte(OutputConfig.SurfaceLumaAddress + Dst + Offset, *(Frame.LumaPtr + Src + Offset));
vmm.WriteByte(outputConfig.SurfaceLumaAddress + dst + offset, *(frame.LumaPtr + src + offset));
}
}
//Copy chroma data from both channels with interleaving.
for (int Y = 0; Y < HalfHeight; Y++)
for (int y = 0; y < halfHeight; y++)
{
int Src = Y * HalfSrcWidth;
int Dst = Y * AlignedWidth;
int src = y * halfSrcWidth;
int dst = y * alignedWidth;
for (int X = 0; X < HalfWidth; X++)
for (int x = 0; x < halfWidth; x++)
{
Vmm.WriteByte(OutputConfig.SurfaceChromaUAddress + Dst + X * 2 + 0, *(Frame.ChromaBPtr + Src + X));
Vmm.WriteByte(OutputConfig.SurfaceChromaUAddress + Dst + X * 2 + 1, *(Frame.ChromaRPtr + Src + X));
vmm.WriteByte(outputConfig.SurfaceChromaUAddress + dst + x * 2 + 0, *(frame.ChromaBPtr + src + x));
vmm.WriteByte(outputConfig.SurfaceChromaUAddress + dst + x * 2 + 1, *(frame.ChromaRPtr + src + x));
}
}
}
private void ThrowUnimplementedCodec()
{
throw new NotImplementedException("Codec \"" + CurrentVideoCodec + "\" is not supported!");
throw new NotImplementedException("Codec \"" + _currentVideoCodec + "\" is not supported!");
}
private void ThrowUnimplementedPixelFormat(SurfacePixelFormat PixelFormat)
private void ThrowUnimplementedPixelFormat(SurfacePixelFormat pixelFormat)
{
throw new NotImplementedException("Pixel format \"" + PixelFormat + "\" is not supported!");
throw new NotImplementedException("Pixel format \"" + pixelFormat + "\" is not supported!");
}
}
}