Skip to content

Commit

Permalink
screens4: movie related fixes
Browse files Browse the repository at this point in the history
- fixed GetFrame() being called outside the rendering thread and
subsequent crashes
- fixed horizontal stride for non-multiple-of-16-width h.264 videos
(Media Foundation, you lying cow!)
  • Loading branch information
kebby committed Dec 21, 2012
1 parent 1aa95b8 commit b4cb15d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
5 changes: 5 additions & 0 deletions altona_wz4/wz4/screens4/movieplayer_win7.cpp
Expand Up @@ -589,6 +589,11 @@ class sMoviePlayerMF : public sMoviePlayer
// was probably padded to 16 lines (h.264 limitation)
sInt stride = RawStride?RawStride:Info.XSize;
sInt extralines = ((size*2/3)/stride)-Info.YSize;
if (extralines>0)
{
stride = sAlign(stride,16); // actually, the stride we get from MF is a lie.
extralines = ((size*2/3)/stride)-Info.YSize;
}

// copy to y,v,u texture
sTexture2D *ytex=Mtrl->Texture[0]->CastTex2D();
Expand Down
37 changes: 21 additions & 16 deletions altona_wz4/wz4/screens4/playlists.cpp
Expand Up @@ -261,9 +261,28 @@ NewSlideData* PlaylistMgr::OnFrame(sF32 delta, const sChar *doneId, sBool doneHa
Time += delta;

NewSlideData *nsd = PreparedSlide;
PreparedSlide = 0;

if (nsd && nsd->Type == VIDEO)
{
// wait for first frame to be fully decoded. must be in rendering thread, thus here.
if (nsd->Movie->GetInfo().XSize<0)
{
nsd->Error = sTRUE;
sRelease(nsd->Movie);
}
else
{
sFRect uvr;
nsd->Movie->GetFrame(uvr);
if (nsd->Movie->GetInfo().XSize==0 || uvr.SizeX()==0)
nsd = 0;
}
}

if (nsd)
{
PreparedSlide = 0;

// prepare auto advance
if (CurrentDuration>0)
CurrentSwitchTime = Time;
Expand Down Expand Up @@ -794,21 +813,7 @@ void PlaylistMgr::PrepareThreadFunc(sThread *t)
nsd->Movie = sCreateMoviePlayer(filename,sMOF_DONTSTART|(item->Mute?sMOF_NOSOUND:0));
if (nsd->Movie)
{
// wait for first frame to be fully decoded
sFRect uvr;
if (nsd->Movie->GetInfo().XSize<0)
{
nsd->Error = sTRUE;
sRelease(nsd->Movie);
}
else
{
while (nsd->Movie->GetInfo().XSize==0 || uvr.SizeX()==0)
{
sSleep(5);
nsd->Movie->GetFrame(uvr);
}
}

}
else
{
Expand Down

0 comments on commit b4cb15d

Please sign in to comment.