PREAMBLE. This document tries to explain in some words what DGA is in general and what the DGA video output driver for MPlayer can do (and what it can't).
WHAT IS DGA.
DGA is short for Direct Graphics
Access and is a means for a program to bypass the X server and
directly modifying the framebuffer memory. Technically spoken this happens
by mapping the framebuffer memory into the memory range of your process.
This is allowed by the kernel only if you have superuser privileges. You
can get these either by logging in as
root or by setting the SUID bit on the
MPlayer executable (not
There are two versions of DGA: DGA1 is used by XFree 3.x.x and DGA2 was introduced with XFree 4.0.1.
DGA1 provides only direct framebuffer access as described above. For switching the resolution of the video signal you have to rely on the XVidMode extension.
DGA2 incorporates the features of XVidMode extension and also allows switching the depth of the display. So you may, although basically running a 32 bit depth X server, switch to a depth of 15 bits and vice versa.
However DGA has some drawbacks. It seems it is somewhat dependent on the graphics chip you use and on the implementation of the X server's video driver that controls this chip. So it does not work on every system...
INSTALLING DGA SUPPORT FOR MPLAYER. First make sure X loads the DGA extension, see in /var/log/XFree86.0.log:
(II) Loading extension XFree86-DGA
See, XFree86 4.0.x or greater is highly recommended! MPlayer's DGA driver is autodetected by ./configure, or you can force it with --enable-dga.
If the driver couldn't switch to a smaller resolution, experiment with options -vm (only with X 3.3.x), -fs, -bpp, -zoom to find a video mode that the movie fits in. There is no converter right now :(
root. DGA needs root
access to be able to write directly video memory. If you want to run it as
user, then install MPlayer SUID root:
Now it works as a simple user, too.
This is a big security risk! Never do this on a server or on a computer that can be accessed by other people because they can gain root privileges through SUID root MPlayer.
Now use -vo dga option, and there you go! (hope so:) You should also try if the -vo sdl:driver=dga option works for you! It's much faster!
RESOLUTION SWITCHING. The DGA driver allows for switching the resolution of the output signal. This avoids the need for doing (slow) software scaling and at the same time provides a fullscreen image. Ideally it would switch to the exact resolution (except for honoring aspect ratio) of the video data, but the X server only allows switching to resolutions predefined in /etc/X11/XF86Config (/etc/X11/XF86Config-4 for XFree 4.X.X respectively). Those are defined by so-called modelines and depend on the capabilities of your video hardware. The X server scans this config file on startup and disables the modelines not suitable for your hardware. You can find out which modes survive with the X11 log file. It can be found at: /var/log/XFree86.0.log.
These entries are known to work fine with a Riva128 chip, using the nv.o X server driver module.
Section "Modes" Identifier "Modes" Modeline "800x600" 40 800 840 968 1056 600 601 605 628 Modeline "712x600" 35.0 712 740 850 900 400 410 412 425 Modeline "640x480" 25.175 640 664 760 800 480 491 493 525 Modeline "400x300" 20 400 416 480 528 300 301 303 314 Doublescan Modeline "352x288" 25.10 352 368 416 432 288 296 290 310 Modeline "352x240" 15.750 352 368 416 432 240 244 246 262 Doublescan Modeline "320x240" 12.588 320 336 384 400 240 245 246 262 Doublescan EndSection
DGA & MPLAYER. DGA is used in two places with MPlayer: The SDL driver can be made to make use of it (-vo sdl:driver=dga) and within the DGA driver (-vo dga). The above said is true for both; in the following sections I'll explain how the DGA driver for MPlayer works.
FEATURES. The DGA driver is invoked by specifying -vo dga at the command line. The default behavior is to switch to a resolution matching the original resolution of the video as close as possible. It deliberately ignores the -vm and -fs options (enabling of video mode switching and fullscreen) - it always tries to cover as much area of your screen as possible by switching the video mode, thus refraining from using additional cycles of your CPU to scale the image. If you don't like the mode it chooses you may force it to choose the mode matching closest the resolution you specify by -x and -y. By providing the -v option, the DGA driver will print, among a lot of other things, a list of all resolutions supported by your current XF86Config file. Having DGA2 you may also force it to use a certain depth by using the -bpp option. Valid depths are 15, 16, 24 and 32. It depends on your hardware whether these depths are natively supported or if a (possibly slow) conversion has to be done.
If you should be lucky enough to have enough offscreen memory left to put a whole image there, the DGA driver will use double buffering, which results in much smoother movie playback. It will tell you whether double buffering is enabled or not.
Double buffering means that the next frame of your video is being drawn in some offscreen memory while the current frame is being displayed. When the next frame is ready, the graphics chip is just told the location in memory of the new frame and simply fetches the data to be displayed from there. In the meantime the other buffer in memory will be filled again with new video data.
Double buffering may be switched on by using the option -double and may be disabled with -nodouble. Current default option is to disable double buffering. When using the DGA driver, onscreen display (OSD) only works with double buffering enabled. However, enabling double buffering may result in a big speed penalty (on my K6-II+ 525 it used an additional 20% of CPU time!) depending on the implementation of DGA for your hardware.
SPEED ISSUES. Generally spoken, DGA framebuffer access should be at least as fast as using the X11 driver with the additional benefit of getting a fullscreen image. The percentage speed values printed by MPlayer have to be interpreted with some care, as for example, with the X11 driver they do not include the time used by the X server needed for the actual drawing. Hook a terminal to a serial line of your box and start top to see what is really going on in your box.
Generally spoken, the speedup done by using DGA against 'normal' use of X11 highly depends on your graphics card and how well the X server module for it is optimized.
If you have a slow system, better use 15 or 16 bit depth since they require only half the memory bandwidth of a 32 bit display.
Using a depth of 24 bit is a good idea even if your card natively just supports 32 bit depth since it transfers 25% less data compared to the 32/32 mode.
I've seen some AVI files be played back on a Pentium MMX 266. AMD K6-2 CPUs might work at 400 MHZ and above.
KNOWN BUGS. Well, according to some developers of XFree, DGA is quite a beast. They tell you better not to use it. Its implementation is not always flawless with every chipset driver for XFree out there.
With XFree 4.0.3 and nv.o there is a bug resulting in strange colors.
ATI driver requires to switch mode back more than once after finishing using of DGA.
Some drivers simply fail to switch back to normal resolution (use Ctrl-Alt-Keypad + and Ctrl-Alt-Keypad - to switch back manually).
Some drivers simply display strange colors.
Some drivers lie about the amount of memory they map into the process's address space, thus vo_dga won't use double buffering (SIS?).
Some drivers seem to fail to report even a single valid mode. In this case the DGA driver will crash telling you about a nonsense mode of 100000x100000 or something like that.
OSD only works with double buffering enabled (else it flickers).