fix some scenarios where video pointers should not be replaced

pull/50/head
cosmonaut 2023-06-13 19:18:23 -07:00
parent b65d4e391c
commit c83997609f
2 changed files with 25 additions and 13 deletions

View File

@ -17,7 +17,7 @@ namespace MoonWorks.Video
public uint yStride; public uint yStride;
public uint uvStride; public uint uvStride;
public bool FrameDataUpdated { get; private set; } public bool FrameDataUpdated { get; set; }
bool IsDisposed; bool IsDisposed;
@ -43,22 +43,33 @@ namespace MoonWorks.Video
public void ReadNextFrame() public void ReadNextFrame()
{ {
lock (this) lock (this)
{
if (!Ended)
{ {
if (Dav1dfile.df_readvideo( if (Dav1dfile.df_readvideo(
Handle, Handle,
1, 1,
out yDataHandle, out var yDataHandle,
out uDataHandle, out var uDataHandle,
out vDataHandle, out var vDataHandle,
out yDataLength, out var yDataLength,
out uvDataLength, out var uvDataLength,
out yStride, out var yStride,
out uvStride) == 1 out var uvStride) == 1
) { ) {
this.yDataHandle = yDataHandle;
this.uDataHandle = uDataHandle;
this.vDataHandle = vDataHandle;
this.yDataLength = yDataLength;
this.uvDataLength = uvDataLength;
this.yStride = yStride;
this.uvStride = uvStride;
FrameDataUpdated = true; FrameDataUpdated = true;
} }
} }
} }
}
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {

View File

@ -170,6 +170,7 @@ namespace MoonWorks.Video
if (CurrentStream.FrameDataUpdated) if (CurrentStream.FrameDataUpdated)
{ {
UpdateRenderTexture(); UpdateRenderTexture();
CurrentStream.FrameDataUpdated = false;
} }
currentFrame = thisFrame; currentFrame = thisFrame;