[MPlayer-dev-eng] Fast OpenGL playback

Stephen Webb swebb at netlab.uky.edu
Tue Nov 9 02:13:51 CET 2004


Attached are the files.  I'm working from a 1.0-pre5 codebase.  I hijacked
the vo_gl.c module -- of course with a few changes you can call it
whatever you want.

Please please keep in mind that this is a total hack for my
prototyping/testing purposes, and isn't intended to be integrated into the
codebase in its current form.  If there is interest in it, I may be able
to write it the "correct" way (I'm still learning how MPlayer is designed
/ structured).  

As was mentioned before, the OpenGL support in MPlayer is
primarily for portability reasons, and since this uses some hardware
specific features, it kind of kills the portability of it.  For playback
purposes, the other VO modules are probably preferable.  For streaming
video into an OpenGL application, however, this code could be
useful.  (Actually in its current state it may not be too useful.  There
would have to be some way to export the frames to another app that does
the OpenGL part (shared memory, e.g.).  I think there was some vo_shm
project started already?  I'm not sure if/how it would fit with this.

Finally, keep in mind you are going to need Cg and GLEW to compile the
code.  I added the following to the generic library part of the Makefile
(hacked it -- not sure of the correct way to do it)
 
-lCg -lCgGL -lGLEW

I'd be glad to help out if I can, but keep in mind I've only been working
with the Mplayer code for a few days, so I'm likely to do everything all
wrong.  :)

-Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vo_gl.c
Type: text/x-csrc
Size: 19748 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20041108/a5917935/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vo_gl.c.1.0pre5.diff
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20041108/a5917935/attachment.txt>
-------------- next part --------------
void yuv2rgb(         float2 tcoord0 : TEXCOORD0,
                          uniform sampler2D texture0,
                          uniform sampler2D texture1,
                          uniform sampler2D texture2,
                     out  float4 oColor : COLOR ) {
  float4 color;
  /* sample the textures and apply the offsets */ 
  color.r = tex2D( texture0, tcoord0 ) - 0.0625;
  color.g = tex2D( texture1, tcoord0 ) - 0.5;
  color.b = tex2D( texture2, tcoord0 ) - 0.5;
 
  /* it may seem like using mul( vec, color ) would be faster, but 
   * it's not for me.  Also multiplying color through a matrix is 
   * slower.  Also, using half precision, fixed precision or integers
   * all *slow down* the program (maybe half runs the same speed). 
   * This may not be optimized for other hardware, especially some
   * hardware doesn't allow indexing into 3 different textures with
   * one texture coordinate, so the program may not run at all.
   */
  oColor.r = (1.164 * color.r + 1.596 * color.b ) ;
  oColor.g = (1.164 * color.r - 0.813 * color.b  - 0.391 * color.g );
  oColor.b = (1.164 * color.r + 2.018 * color.g ); 
}


More information about the MPlayer-dev-eng mailing list