Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions FNA.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,12 @@
<Compile Include="src\Media\SongCollection.cs" />
<Compile Include="src\Media\VideoSoundtrackType.cs" />
<Compile Include="src\Media\VisualizationData.cs" />
<Compile Include="src\Media\Xiph\BaseYUVPlayer.cs" />
<Compile Include="src\Media\Xiph\IVideoPlayerCodec.cs" />
<Compile Include="src\Media\Xiph\Video.cs" />
<Compile Include="src\Media\Xiph\VideoPlayer.cs" />
<Compile Include="src\Media\Xiph\VideoPlayerAV1.cs" />
<Compile Include="src\Media\Xiph\VideoPlayerTheora.cs" />
<Compile Include="src\NamespaceDocs.cs" />
<Compile Include="src\Plane.cs" />
<Compile Include="src\PlaneIntersectionType.cs" />
Expand Down Expand Up @@ -357,6 +361,7 @@
<Compile Include="lib\SDL3-CS\SDL3\SDL3.Legacy.cs" />
<Compile Include="lib\FAudio\csharp\FAudio.cs" />
<Compile Include="lib\Theorafile\csharp\Theorafile.cs" />
<Compile Include="lib\dav1dfile\csharp\dav1dfile.Legacy.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand All @@ -383,5 +388,8 @@
<EmbeddedResource Include="src\Graphics\Effect\YUVToRGBA\YUVToRGBAEffect.fxb">
<LogicalName>Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffect.fxb</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Graphics\Effect\YUVToRGBA\YUVToRGBAEffectR.fxb">
<LogicalName>Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffectR.fxb</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions FNA.NetFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,12 @@
<Compile Include="src\Media\SongCollection.cs" />
<Compile Include="src\Media\VideoSoundtrackType.cs" />
<Compile Include="src\Media\VisualizationData.cs" />
<Compile Include="src\Media\Xiph\BaseYUVPlayer.cs" />
<Compile Include="src\Media\Xiph\IVideoPlayerCodec.cs" />
<Compile Include="src\Media\Xiph\Video.cs" />
<Compile Include="src\Media\Xiph\VideoPlayer.cs" />
<Compile Include="src\Media\Xiph\VideoPlayerAV1.cs" />
<Compile Include="src\Media\Xiph\VideoPlayerTheora.cs" />
<Compile Include="src\NamespaceDocs.cs" />
<Compile Include="src\Plane.cs" />
<Compile Include="src\PlaneIntersectionType.cs" />
Expand Down Expand Up @@ -358,6 +362,7 @@
<Compile Include="lib\SDL3-CS\SDL3\SDL3.Legacy.cs" />
<Compile Include="lib\FAudio\csharp\FAudio.cs" />
<Compile Include="lib\Theorafile\csharp\Theorafile.cs" />
<Compile Include="lib\dav1dfile\csharp\dav1dfile.Legacy.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand All @@ -384,5 +389,8 @@
<EmbeddedResource Include="src\Graphics\Effect\YUVToRGBA\YUVToRGBAEffect.fxb">
<LogicalName>Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffect.fxb</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Graphics\Effect\YUVToRGBA\YUVToRGBAEffectR.fxb">
<LogicalName>Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffectR.fxb</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions FNA.NetStandard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,12 @@
<Compile Include="src\Media\SongCollection.cs" />
<Compile Include="src\Media\VideoSoundtrackType.cs" />
<Compile Include="src\Media\VisualizationData.cs" />
<Compile Include="src\Media\Xiph\BaseYUVPlayer.cs" />
<Compile Include="src\Media\Xiph\IVideoPlayerCodec.cs" />
<Compile Include="src\Media\Xiph\Video.cs" />
<Compile Include="src\Media\Xiph\VideoPlayer.cs" />
<Compile Include="src\Media\Xiph\VideoPlayerAV1.cs" />
<Compile Include="src\Media\Xiph\VideoPlayerTheora.cs" />
<Compile Include="src\NamespaceDocs.cs" />
<Compile Include="src\Plane.cs" />
<Compile Include="src\PlaneIntersectionType.cs" />
Expand Down Expand Up @@ -356,6 +360,7 @@
<Compile Include="lib\SDL3-CS\SDL3\SDL3.Legacy.cs" />
<Compile Include="lib\FAudio\csharp\FAudio.cs" />
<Compile Include="lib\Theorafile\csharp\Theorafile.cs" />
<Compile Include="lib\dav1dfile\csharp\dav1dfile.Legacy.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand All @@ -382,5 +387,8 @@
<EmbeddedResource Include="src\Graphics\Effect\YUVToRGBA\YUVToRGBAEffect.fxb">
<LogicalName>Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffect.fxb</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Graphics\Effect\YUVToRGBA\YUVToRGBAEffectR.fxb">
<LogicalName>Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffectR.fxb</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions FNA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,12 @@
<Compile Include="src\Media\SongCollection.cs" />
<Compile Include="src\Media\VideoSoundtrackType.cs" />
<Compile Include="src\Media\VisualizationData.cs" />
<Compile Include="src\Media\Xiph\BaseYUVPlayer.cs" />
<Compile Include="src\Media\Xiph\IVideoPlayerCodec.cs" />
<Compile Include="src\Media\Xiph\Video.cs" />
<Compile Include="src\Media\Xiph\VideoPlayer.cs" />
<Compile Include="src\Media\Xiph\VideoPlayerAV1.cs" />
<Compile Include="src\Media\Xiph\VideoPlayerTheora.cs" />
<Compile Include="src\NamespaceDocs.cs" />
<Compile Include="src\Plane.cs" />
<Compile Include="src\PlaneIntersectionType.cs" />
Expand Down Expand Up @@ -428,6 +432,7 @@
<Compile Include="lib\SDL3-CS\SDL3\SDL3.Legacy.cs" />
<Compile Include="lib\FAudio\csharp\FAudio.cs" />
<Compile Include="lib\Theorafile\csharp\Theorafile.cs" />
<Compile Include="lib\dav1dfile\csharp\dav1dfile.Legacy.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">
Expand Down Expand Up @@ -457,5 +462,8 @@
<EmbeddedResource Include="src\Graphics\Effect\YUVToRGBA\YUVToRGBAEffect.fxb">
<LogicalName>Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffect.fxb</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="src\Graphics\Effect\YUVToRGBA\YUVToRGBAEffectR.fxb">
<LogicalName>Microsoft.Xna.Framework.Graphics.Effect.Resources.YUVToRGBAEffectR.fxb</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Project>
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,12 @@ SRC = \
src/Media/SongCollection.cs \
src/Media/VideoSoundtrackType.cs \
src/Media/VisualizationData.cs \
src/Media/Xiph/IVideoPlayerCodec.cs \
src/Media/Xiph/BaseYUVPlayer.cs \
src/Media/Xiph/Video.cs \
src/Media/Xiph/VideoPlayer.cs \
src/Media/Xiph/VideoPlayerTheora.cs \
src/Media/Xiph/VideoPlayerAV1.cs \
src/NamespaceDocs.cs \
src/Plane.cs \
src/PlaneIntersectionType.cs \
Expand All @@ -339,7 +343,8 @@ SRC = \
lib/SDL2-CS/src/SDL2.cs \
lib/SDL3-CS/SDL3/SDL3.Legacy.cs \
lib/FAudio/csharp/FAudio.cs \
lib/Theorafile/csharp/Theorafile.cs
lib/Theorafile/csharp/Theorafile.cs \
lib/dav1dfile/csharp/dav1dfile.Legacy.cs

RESDIR = src/Graphics/Effect/StockEffects/FXB
RESNAME = Microsoft.Xna.Framework.Graphics.Effect.Resources
Expand All @@ -350,7 +355,8 @@ RES = \
-resource:$(RESDIR)/EnvironmentMapEffect.fxb,$(RESNAME).EnvironmentMapEffect.fxb \
-resource:$(RESDIR)/SkinnedEffect.fxb,$(RESNAME).SkinnedEffect.fxb \
-resource:$(RESDIR)/SpriteEffect.fxb,$(RESNAME).SpriteEffect.fxb \
-resource:src/Graphics/Effect/YUVToRGBA/YUVToRGBAEffect.fxb,$(RESNAME).YUVToRGBAEffect.fxb
-resource:src/Graphics/Effect/YUVToRGBA/YUVToRGBAEffect.fxb,$(RESNAME).YUVToRGBAEffect.fxb \
-resource:src/Graphics/Effect/YUVToRGBA/YUVToRGBAEffectR.fxb,$(RESNAME).YUVToRGBAEffectR.fxb

# Targets

Expand Down
4 changes: 4 additions & 0 deletions app.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<dllmap dll="FAudio" os="osx" target="libFAudio.0.dylib"/>
<dllmap dll="FAudio" os="linux,freebsd,netbsd" target="libFAudio.so.0"/>

<dllmap dll="dav1dfile" os="windows" target="libdav1dfile.dll"/>
<dllmap dll="dav1dfile" os="osx" target="libdav1dfile.1.dylib"/>
<dllmap dll="dav1dfile" os="linux,freebsd,netbsd" target="libdav1dfile.so.0"/>

<!-- Deprecated! -->
<dllmap dll="SDL2" os="windows" target="SDL2.dll"/>
<dllmap dll="SDL2" os="osx" target="libSDL2-2.0.0.dylib"/>
Expand Down
2 changes: 1 addition & 1 deletion lib/SDL3-CS
13 changes: 13 additions & 0 deletions src/Graphics/Effect/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ public static byte[] YUVToRGBAEffect
}
}

public static byte[] YUVToRGBAEffectR
{
get
{
if (yuvToRGBAEffectR == null)
{
yuvToRGBAEffectR = GetResource("YUVToRGBAEffectR");
}
return yuvToRGBAEffectR;
}
}

#endregion

#region Private Static Variables
Expand All @@ -113,6 +125,7 @@ public static byte[] YUVToRGBAEffect
private static byte[] skinnedEffect;
private static byte[] spriteEffect;
private static byte[] yuvToRGBAEffect;
private static byte[] yuvToRGBAEffectR;

#endregion

Expand Down
64 changes: 64 additions & 0 deletions src/Graphics/Effect/YUVToRGBA/YUVToRGBAEffectR.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* YUV-to-RGBA Effect
* Written by Ethan "flibitijibibo" Lee
* http://www.flibitijibibo.com/
*
* This effect is based on the YUV-to-RGBA GLSL shader found in SDL.
* Thus, it also released under the zlib license:
* http://libsdl.org/license.php
*/

sampler samp0 : register(s0);
sampler samp1 : register(s1);
sampler samp2 : register(s2);

float4 RescaleFactor : register(ps, c0) = float4(1, 1, 1, 1);

void VS(inout float2 tex : TEXCOORD0,
inout float4 pos : SV_Position)
{
pos.w = 1.0;
}

float4 PS(float2 tex : TEXCOORD0) : SV_Target0
{
const float3 offset = float3(-0.0625, -0.5, -0.5);

/* More info about colorspace conversion:
* http://www.equasys.de/colorconversion.html
* http://www.equasys.de/colorformat.html
*/
#if 1
/* ITU-R BT.709 */
const float3 Rcoeff = float3(1.164, 0.000, 1.793);
const float3 Gcoeff = float3(1.164, -0.213, -0.533);
const float3 Bcoeff = float3(1.164, 2.112, 0.000);
#else
/* ITU-R BT.601 */
const float3 Rcoeff = float3(1.164, 0.000, 1.596);
const float3 Gcoeff = float3(1.164, -0.391, -0.813);
const float3 Bcoeff = float3(1.164, 2.018, 0.000);
#endif

float3 yuv;
yuv.x = tex2D(samp0, tex).r;
yuv.y = tex2D(samp1, tex).r;
yuv.z = tex2D(samp2, tex).r;
yuv *= RescaleFactor;
yuv += offset;

float4 rgba;
rgba.x = dot(yuv, Rcoeff);
rgba.y = dot(yuv, Gcoeff);
rgba.z = dot(yuv, Bcoeff);
rgba.w = 1.0;
return rgba;
}

Technique T
{
Pass P
{
VertexShader = compile vs_3_0 VS();
PixelShader = compile ps_3_0 PS();
}
}
Binary file not shown.
8 changes: 8 additions & 0 deletions src/Graphics/SurfaceFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,13 @@ public enum SurfaceFormat
/// BC7 block texture format where the R/G/B values are non-linear sRGB.
/// </summary>
Bc7SrgbEXT,
/// <summary>
/// Unsigned 8-bit R pixel format.
/// </summary>
ByteEXT,
/// <summary>
/// Unsigned 16-bit R pixel format.
/// </summary>
UShortEXT,
}
}
4 changes: 4 additions & 0 deletions src/Graphics/Texture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public static int GetBlockSizeSquaredEXT(SurfaceFormat format)
case SurfaceFormat.Vector2:
case SurfaceFormat.HdrBlendable:
case SurfaceFormat.Vector4:
case SurfaceFormat.ByteEXT:
case SurfaceFormat.UShortEXT:
return 1;
default:
throw new ArgumentException("Should be a value defined in SurfaceFormat", "Format");
Expand All @@ -149,12 +151,14 @@ public static int GetFormatSizeEXT(SurfaceFormat format)
case SurfaceFormat.Bc7SrgbEXT:
return 16;
case SurfaceFormat.Alpha8:
case SurfaceFormat.ByteEXT:
return 1;
case SurfaceFormat.Bgr565:
case SurfaceFormat.Bgra4444:
case SurfaceFormat.Bgra5551:
case SurfaceFormat.HalfSingle:
case SurfaceFormat.NormalizedByte2:
case SurfaceFormat.UShortEXT:
return 2;
case SurfaceFormat.Color:
case SurfaceFormat.Single:
Expand Down
4 changes: 3 additions & 1 deletion src/Graphics/Texture2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ SurfaceFormat format
format != SurfaceFormat.HalfSingle &&
format != SurfaceFormat.HalfVector2 &&
format != SurfaceFormat.HalfVector4 &&
format != SurfaceFormat.HdrBlendable )
format != SurfaceFormat.HdrBlendable &&
format != SurfaceFormat.ByteEXT &&
format != SurfaceFormat.UShortEXT)
{
// Not a renderable format period
Format = SurfaceFormat.Color;
Expand Down
Loading
Loading