Skip to content

Commit

Permalink
Merge branch 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan McGrath committed Jun 5, 2024
2 parents aa39d85 + a72fe7b commit bc669aa
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 92 deletions.
2 changes: 1 addition & 1 deletion FNA.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<EnableDefaultItems>false</EnableDefaultItems>
Expand Down
2 changes: 1 addition & 1 deletion lib/FNA3D
2 changes: 1 addition & 1 deletion lib/SDL2-CS
Submodule SDL2-CS updated 1 files
+1 −1 SDL2-CS.Core.csproj
6 changes: 3 additions & 3 deletions src/Content/ContentReaders/SongReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ protected internal override Song Read(ContentReader input, Song existingInstance
/* The path string includes the ".wma" extension. Let's see if this
* file exists in a format we actually support...
*/
path = Normalize(path.Substring(0, path.Length - 4));
if (String.IsNullOrEmpty(path))
string realPath = Normalize(path.Substring(0, path.Length - 4));
if (!String.IsNullOrEmpty(realPath))
{
throw new ContentLoadException();
path = realPath;
}

int durationMs = input.ReadInt32();
Expand Down
6 changes: 3 additions & 3 deletions src/Content/ContentReaders/VideoReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ Video existingInstance
/* The path string includes the ".wmv" extension. Let's see if this
* file exists in a format we actually support...
*/
path = Normalize(path.Substring(0, path.Length - 4));
if (String.IsNullOrEmpty(path))
string realPath = Normalize(path.Substring(0, path.Length - 4));
if (!String.IsNullOrEmpty(realPath))
{
throw new ContentLoadException();
path = realPath;
}

int durationMS = input.ReadObject<int>();
Expand Down
106 changes: 50 additions & 56 deletions src/Media/Xiph/Video.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,20 @@ public sealed class Video

public int Width
{
get
{
return yWidth;
}
get;
private set;
}

public int Height
{
get
{
return yHeight;
}
get;
private set;
}

public float FramesPerSecond
{
get
{
return (float) fps;
}
get;
private set;
}

public VideoSoundtrackType VideoSoundtrackType
Expand Down Expand Up @@ -69,14 +63,9 @@ internal GraphicsDevice GraphicsDevice

#endregion

#region Internal Variables: Theorafile
#region Internal Variables

internal IntPtr theora;
internal int yWidth;
internal int yHeight;
internal int uvWidth;
internal int uvHeight;
internal double fps;
internal string handle;
internal bool needsDurationHack;

#endregion
Expand All @@ -85,38 +74,36 @@ internal GraphicsDevice GraphicsDevice

internal Video(string fileName, GraphicsDevice device)
{
handle = fileName;
GraphicsDevice = device;

/* This is the raw file constructor; unlike the XNB
* constructor we can be up front about files not
* existing, so let's do that!
*/
if (!File.Exists(fileName))
{
throw new FileNotFoundException(fileName);
}

IntPtr theora;
int width;
int height;
double fps;
Theorafile.th_pixel_fmt fmt;
Theorafile.tf_fopen(fileName, out theora);
Theorafile.tf_videoinfo(
theora,
out yWidth,
out yHeight,
out width,
out height,
out fps,
out fmt
);
if (fmt == Theorafile.th_pixel_fmt.TH_PF_420)
{
uvWidth = yWidth / 2;
uvHeight = yHeight / 2;
}
else if (fmt == Theorafile.th_pixel_fmt.TH_PF_422)
{
uvWidth = yWidth / 2;
uvHeight = yHeight;
}
else if (fmt == Theorafile.th_pixel_fmt.TH_PF_444)
{
uvWidth = yWidth;
uvHeight = yHeight;
}
else
{
throw new NotSupportedException(
"Unrecognized YUV format!"
);
}
Theorafile.tf_close(ref theora);

Width = width;
Height = height;
FramesPerSecond = (float) fps;

// FIXME: This is a part of the Duration hack!
Duration = TimeSpan.MaxValue;
Expand All @@ -131,7 +118,19 @@ internal Video(
int height,
float framesPerSecond,
VideoSoundtrackType soundtrackType
) : this(fileName, device) {
) {
handle = fileName;
GraphicsDevice = device;

/* This is the XNB constructor, which really just loads
* the metadata without actually loading the video. For
* accuracy's sake we have to wait until VideoPlayer
* tries to load this before throwing Exceptions.
*/
Width = width;
Height = height;
FramesPerSecond = framesPerSecond;

// FIXME: Oh, hey! I wish we had this info in Theora!
Duration = TimeSpan.FromMilliseconds(durationMS);
needsDurationHack = false;
Expand Down Expand Up @@ -168,23 +167,18 @@ public static Video FromUriEXT(Uri uri, GraphicsDevice graphicsDevice)
return new Video(path, graphicsDevice);
}

public void SetAudioTrackEXT(int track)
{
if (theora != IntPtr.Zero)
{
Theorafile.tf_setaudiotrack(theora, track);
}
}

#endregion
// FIXME: These should be in VideoPlayer instead!

#region Destructor
internal int audioTrack = -1;
internal int videoTrack = -1;
internal VideoPlayer parent;

~Video()
public void SetAudioTrackEXT(int track)
{
if (theora != IntPtr.Zero)
audioTrack = track;
if (parent != null)
{
Theorafile.tf_close(ref theora);
parent.SetAudioTrackEXT(track);
}
}

Expand Down
Loading

0 comments on commit bc669aa

Please sign in to comment.