The Chromakeyed OSD
This changes the Xv and XvMC display methods from using a blended YUV overlay
to using the chromakey window behind the video. This removes the OSD
processing from the timing-critical code where you're trying to stay on a
strict schedule for frame rendering, and I have found it tremendously helped
eliminate delays in frame rendering which I believe cause the "prebuffering
pause" problem when the OSD is displaying.
It also prevents us from having to render and alpha-blend the OSD for every
single frame. Because the chromakey window is persistant, the OSD rendering
only needs to do hard work when the OSD changes. This also means that, if the
video is not filling the screen (i.e. letterbox-ing or pillar-ing), we can
(and do) still use the full screen for the OSD.
Lastly, you get full color for the OSD of course. :-)
The results are surprisingly good. I initially did some experimentation with
putting text and images on the chromakey background window, and was
sufficiently encouraged by the results to go ahead and do this full-fledged
proof of concept implementation.
Drawbacks
- You give up translucency in the OSD. You still have the equivalent of
transparency courtesy of chromakey.
- The OSD is still rendered as YUV, and this code converts it to RGB. It
would be much better if it were simply rendered as RGB, but a) this is a proof
of concept and b) I haven't figured out how to do that yet. :-)
- Some may consider it a drawback that this spawns an additional thread just
to manage the OSD. I did it that way so that the OSD display activity is
partitioned away from the video and audio playing activity. This allows the
OSD activity to be run at a very low priority, and it allows adjustment of the
rate at which the OSD is (re-)evaluated. At present it's set to check the OSD
every 33333 usecs, which roughly corresponds to 30 fps. It could just as
easily be a higher (slower) value, though, to reduce CPU usage by this thread
at a cost of a slightly less responsive OSD.
- The OSD fonts are anti-aliased, which can make the edges look strange
under some circumstances since the anti-aliasing doesn't understand that black
is actually "transparent". I tried to combat this by using half-toned outline
colors, but it's not entirely successful.
- Since I haven't actually disabled the YUV rendering code for the OSD, you
can get some strange results with certain colors (red?) as the OSD code thinks
it should alpha-modify your colors.
Like I said, it's a proof of concept - not a glossy finished product. This is
intended to stimulate discussion, and to find out if others benefit as much as
I have from moving the OSD processing out of the frame rendering loop.
There is the
patch itself
(last updated 4/20/05) and an
example OSD theme
(last updated 3/23/05) that, despite my complete lack of artistic skilz, attempts
to show what the chromakey OSD can do. Let's just call it (ahem) minimally
artistic. :-)
I have been using both patches for several weeks now on my nforce2 system with
built-in graphics (which has to be some sort of worst case since it's using
main memory), and have found that I can now view 1080i content with near
perfect results. I still encounter the "jumpies" and "old-framies" with 720p
content, but I think that's a different problem.
Notes: