Skip to content

Commit cfdea2e

Browse files
kiddkaffeinekiddkaffeine
authored andcommitted
Update to use df_guessframerate
1 parent f724ce4 commit cfdea2e

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/Media/Xiph/VideoPlayerAV1.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Microsoft.Xna.Framework.Media
88
{
9-
public unsafe class VideoPlayerAV1 : BaseYUVPlayer, IVideoPlayerCodec, IDisposable
9+
internal unsafe class VideoPlayerAV1 : BaseYUVPlayer, IVideoPlayerCodec, IDisposable
1010
{
1111
#region Public Member Data: XNA VideoPlayer Implementation
1212

@@ -234,7 +234,7 @@ public void Play(Video video)
234234
try
235235
{
236236
byte hbd;
237-
Bindings.df_videoinfo2(context, out yWidth, out yHeight, out layout, out hbd, out fps);
237+
Bindings.df_videoinfo2(context, out yWidth, out yHeight, out layout, out hbd);
238238
if (hbd == 2)
239239
{
240240
bitsPerPixel = 12;
@@ -247,10 +247,16 @@ public void Play(Video video)
247247
{
248248
bitsPerPixel = 8;
249249
}
250+
251+
if (Bindings.df_guessframerate(context, out fps) == 0)
252+
{
253+
// If this is not present, I hope someone manually supplied it
254+
fps = Video.FramesPerSecond;
255+
}
250256
} catch {
251257
Bindings.df_videoinfo(context, out yWidth, out yHeight, out layout);
252258
bitsPerPixel = 8;
253-
fps = 0;
259+
fps = Video.FramesPerSecond;
254260
}
255261

256262
int uvWidth, uvHeight;
@@ -284,13 +290,10 @@ public void Play(Video video)
284290

285291
if (fps == 0)
286292
{
287-
if (Video.FramesPerSecond == 0)
288-
{
289-
throw new InvalidOperationException("Framerate not present in header or manually specified");
290-
}
291-
fps = Video.FramesPerSecond;
293+
throw new InvalidOperationException("Framerate not present in header or manually specified");
292294
}
293-
else if (Math.Abs(Video.FramesPerSecond - fps) >= 1.0f)
295+
296+
if (Math.Abs(Video.FramesPerSecond - fps) >= 1.0f)
294297
{
295298
throw new InvalidOperationException(
296299
"XNB/OGV framesPerSecond mismatch!" +
@@ -483,7 +486,12 @@ internal static VideoPlayer.VideoInfo ReadInfo(string fileName)
483486
byte hbd;
484487
double fps;
485488
Bindings.df_fopen(fileName, out context);
486-
Bindings.df_videoinfo2(context, out width, out height, out pixelLayout, out hbd, out fps);
489+
Bindings.df_videoinfo2(context, out width, out height, out pixelLayout, out hbd);
490+
if (Bindings.df_guessframerate(context, out fps) == 0)
491+
{
492+
// I hope someone will manually supply this
493+
fps = 0;
494+
}
487495
Bindings.df_close(context);
488496

489497
return new VideoPlayer.VideoInfo() { fps = fps, width = width, height = height };

0 commit comments

Comments
 (0)