Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "lib/SDL3-CS"]
path = lib/SDL3-CS
url = https://github.com/flibitijibibo/SDL3-CS.git
[submodule "lib/dav1dfile"]
path = lib/dav1dfile
url = https://github.com/MoonsideGames/dav1dfile
5 changes: 5 additions & 0 deletions FNA.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@
<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" />
Expand Down Expand Up @@ -360,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 @@ -386,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>
5 changes: 5 additions & 0 deletions FNA.NetFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@
<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" />
Expand Down Expand Up @@ -361,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 @@ -387,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>
5 changes: 5 additions & 0 deletions FNA.NetStandard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@
<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" />
Expand Down Expand Up @@ -359,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 @@ -385,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>
5 changes: 5 additions & 0 deletions FNA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@
<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" />
Expand Down Expand Up @@ -431,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 @@ -460,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>
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ SRC = \
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 @@ -342,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 @@ -353,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="dav1dfile.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
1 change: 1 addition & 0 deletions lib/dav1dfile
Submodule dav1dfile added at ed01b7
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.
4 changes: 4 additions & 0 deletions src/Media/Xiph/VideoPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,22 @@ public float Volume
internal static Dictionary<string, string> codecExtensions =
new Dictionary<string, string>
{
{ "obu", "AV1" },
{ "av1", "AV1" },
{ "ogv", "Theora" }
};

internal static Dictionary<string, Func<string, VideoInfo>> codecInfoReaders =
new Dictionary<string, Func<string, VideoInfo>>
{
{ "AV1", VideoPlayerAV1.ReadInfo },
{ "Theora", VideoPlayerTheora.ReadInfo }
};

internal static Dictionary<string, Func<IVideoPlayerCodec>> codecPlayers =
new Dictionary<string, Func<IVideoPlayerCodec>>
{
{ "AV1", () => new VideoPlayerAV1() },
{ "Theora", () => new VideoPlayerTheora() },
};

Expand Down
Loading