Re: Movie Rendering in Direct3D
From: Jack Hoxley (Jack.Hoxley_at_DirectX4VB.Com)
Date: 06/29/04
- Next message: Jack Hoxley: "Re: Fast Offscreen Rendering"
- Previous message: Eyal Teler: "Re: Care to recommend a multi-head graphics card...?"
- In reply to: Philip Taylor [ATI]: "Re: Movie Rendering in Direct3D"
- Next in thread: Phil Taylor: "Re: Movie Rendering in Direct3D"
- Reply: Phil Taylor: "Re: Movie Rendering in Direct3D"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 29 Jun 2004 13:19:51 +0100
Thanks Philip,
> methinks you doth exaggerate.
Probably, when I posted it'd been a long, bad, day.
I've walked through the entire sample - written it out on paper, had no
problems with that. I've got something fairly similar to what you wrote out.
My problems came as soon as I tried to change the way the code was
structured and integrate it with what I already have in the engine.
Basically, we only need trivial rendering of movies -
LoadMovie( std::string& )
UnloadMovie( )
PlayMovie( )
PauseMovie( )
StopMovie( )
Anything else should be hidden behind that as mere implementation details -
and not for the use of anyone else.
I'm still trying to work on some of these problems - but here's a rough list
of what's been going wrong:
1. The .lib (strmbase.lib I think) caused no end of LNK2005 errors
(duplicate symbols).
2. The copying of the movie frames was upside down (yet I copy-pasted the
DoRenderSample code!)
3. I'd get only the first few seconds of playback before the image was lost
(audio continued). This just intermittently happened - different times each
test.
4. Crashing when trying to ->Release() the 'CTextureRenderer' based
interface (as is done with the original sample). It threw an unknown
exception (one not derived from std::exception).
5. Problems with namespaces - for whatever reasong the CComPtr<> class won't
work inside my namespaces, so I had to re-write some of the QueryInterface
code.
I know that all 5 of those points are my errors - simply because the sample
obviously works, and my code doesn't. Even though it is a near enough 1:1
mapping copy. I'm also not that experienced with down-and-dirty COM
programming - I quite like to avoid it really ;-)
My frustration mostly came from the fact that the sample has no SDK
documentation (unless its been removed by the latest Beta release I have)
that helps with implementing it, and the sample is very poorly commented -
nothing much above the obvious. So unless I know DShow inside out, and/or
COM then I'm a bit stuffed...
Compared with the unbelievably excellent Direct3D coverage in the SDK I came
to expect a little better.
Anyway, Sorry for all the ranting/waffle. I'll have another crack at the
code after I get some more coffee.
Best Regards,
Jack
"Philip Taylor [ATI]" <ptaylor@online.newsgroup-poster.ati.com> wrote in
message news:ez29URUXEHA.2544@TK2MSFTNGP10.phx.gbl...
> methinks you doth exaggerate.
>
> its not that hard to walk thru the code in the Texture3D sample.
>
> here is what it does.
>
> WinMain
> InitD3D
> InitGeometry
> Set up a timer for rendering ( may not be ideal for all apps )
> MessageLoop
> Kill the timer
> Cleanup
>
> MessageLoop
> Dispatch to WndProc, so examine WM_PAINT, WM_TIMER
> WM_PAINT, WM_TIMER
> Render
>
> so at the top level there are 3 main methods to learn, InitD3D,
> InitGeometry, and Render. Cleanup I will leave as an exercise for the
> reader.
>
> InitD3D - in textures.cpp
> sets up the D3D objects ( d3d, d3ddevice, sets some renderstates )
>
> InitGeometry
> InitDShowTextureRenderer
> create a vertex buffer
> fill the vertex buffer with the grid the texture is rendered onto
>
> Render
> some housekeeping to recover from device lost
> Clear
> BeginScene
> SetupMatrices
> ( only world matrix needs to be set every time in this app, but
> useful in cut-n-paste into another app )
> SetTexture ( to our video texture )
> Render the vertexbuffer
> ( only DrawPrim needs to be called every time in this app, but
> SetStreamSource and SetVertexShader useful in cut-n-paste into another
app )
> EndScene
> Present
> CheckMovieStatus, to see if movie needs to be restarted
>
> now we understand InitDShowTextureRenderer and CheckMovieStatus, DShow
> specific helpers
>
> InitDShowTextureRenderer - in dshowtextures.cpp
> creates the filtergraph
> creates the texture renderer ( CTextureRenderer, local class )
> gets a pointer to the base filter from the texture renderer filter,
add
> it to the graph
> loads the media
> adds the source filter to the graph
> have the graph builder render the source filters output
> filter graph manager will connect the video stream to the loaded
> texture renderer
> thats standard filter graph stuff, eg in->filter->out
> get some housekeeping interfaces ( media control, event, position )
> start the graph running
>
> CheckMovieStatus
> uses the event interface to check for completion
> if completed, set position to start
>
> so now we need to understand CTextureRenderer
>
> constructor
> should AddRef the texture, doesnt do that so thats a possible bug
>
> destructor
> de nada, eg do nothing
> should Release the texture to match the AddRef
>
> CheckMediaType
> reject if not video type
> only accept RGB24 in ( to make it easier for format conversion )
>
> SetMediaType
> get info in size of media
> create a D3DX texture using D3DXCreateTexture
> make sure it returned what we expected
> save format info
>
> DoRenderSample
> verify incoming data pointer and outgoing texture pointer are okay
> get the video buffer pointer
> lock the texture
> copy the bits
> for 2 formats ( X8R8G8B8 and A1R5G5B5, with format conversion )
> unlock texture
>
> thats it in a nutshell, really, was that hard?
>
> you have to explain what part you dont get.
>
> If you want to understand DShow, filtergraphs, etc so that you can change
> the apps behavior in using video - you have no choice but to learn DShow.
> There is quite extensive documentation in the SDK. Start with the player
> samples.
>
> If this is all you want to do, you can consider the job done.
>
>
> "Jack Hoxley" <Jack.Hoxley@DirectX4VB.Com> wrote in message
> news:O3snhBTXEHA.1164@tk2msftngp13.phx.gbl...
> > Hello all,
> >
> > I know I'm a newbie here - usually stick to other places, but given my
> level
> > of desperation I gathered (after the beta-dx newsgroups) this was the
best
> > place to look for answers... :-)
> >
> > Anyway, any of you who know of the DirectShow 'Texture3D' (and
> 'Texture3D9')
> > sample might be able to help. I need to emulate it's features in our
> > graphics engine.
> >
> > Basically, we have a 2D GUI style menu system for the game - and I need
to
> > be able to display a movie from a file (.avi, .mpg etc..) in with the
GUI.
> > It must interact with Direct3D, because there can be other elements
> > on-screen (so its not quite a classical cut-scene problem).
> >
> > Anyway, I'm getting close to thinking it's just not possible. I've not
> found
> > any substantial documentation on the DShow API, and only re-hashings of
> that
> > one SDK sample (so no other working code to go from). No one I've asked,
> > even Microsoft, seems to have anything to help :-(
> >
> > Does anyone know of any tutorials/guides/samples for getting a movie
from
> a
> > file onto a texture? My knowledge of movie playback (and the various
> > WM-SDK/DShow etc.. libraries) is a bit limited - this is my first major
> > collision with the stuff!
> >
> > The Texture3D9 sample is a complete mess - COM objects everywhere,
global
> > variables, random classes - making it extremely difficult to comprehend
> and
> > re-write for my project structure.
> >
> > In fact, if theres anyone here who understands aforementioned sample and
> > would be willing to give me a hand working out what it does...
> >
> > I know I'm asking a lot, but any help is soooooo greatly appreciated
right
> > now!
> > Regards,
> > Jack
> >
> >
>
>
- Next message: Jack Hoxley: "Re: Fast Offscreen Rendering"
- Previous message: Eyal Teler: "Re: Care to recommend a multi-head graphics card...?"
- In reply to: Philip Taylor [ATI]: "Re: Movie Rendering in Direct3D"
- Next in thread: Phil Taylor: "Re: Movie Rendering in Direct3D"
- Reply: Phil Taylor: "Re: Movie Rendering in Direct3D"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|