Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XVideo, anyone used this in their program???

106 views
Skip to first unread message

Alex

unread,
Apr 4, 2003, 3:01:25 AM4/4/03
to
Hello,

I am making a program that has to show a video (from a framegrabber)
in a window with some moving objects on it. To make that moving
objects (figures, drawn bij XDrawRectangle,-Line) they are drawn on
the backgroundpixmap of the window and on the clipmask of the GC.
Ok, so far it works fine. But I want to add, replace or remove those
figures while the video is started and that doesn't work!
I tried to find documentation and found very little.
Second I looked it up in the source-code. I found an xv.c, but the
clipping and starting of the video (using video4linux) is not done
there directly. Later I found v4l.c in the Xserver/hw/drivers/v4l dir.
And this file contains all the xv-functions and found out that Xvideo
creates the clips for Xvideo when you start the video (XvPutVideo). I
couldn't find a Xvideo function that adds clips of your GC.
Because of the date (July 1991) above the xv.c file I tried to look
for a newer version first (I had this one with my SuSe 8.0 distro),
and I didn't seem to find it.
My last idea was to make a function that adds the clips (while the
video is started) myself. But this also gave some problems because
after making and installing XFree86 my new v4l.c hasn't been used (I
added a printf), although the v4l.o objects had the right datestamp.

So please can anyone give me any tips, ideas, experiences or
whatever...

Thanks in advance,
Alex

Steve Kirkendall

unread,
Apr 5, 2003, 12:22:14 PM4/5/03
to
Alex wrote:
>
> I am making a program that has to show a video (from a framegrabber)
> in a window with some moving objects on it. To make that moving
> objects (figures, drawn bij XDrawRectangle,-Line) they are drawn on
> the backgroundpixmap of the window and on the clipmask of the GC.
> Ok, so far it works fine. But I want to add, replace or remove those
> figures while the video is started and that doesn't work!

I'm no expert, but I have used Xv in a visualization plugin for
XMMS, to display animation in the root window underneath any
application windows. I'll take a shot at this.

The most portable way to add graphics on top of video (if you
don't want to manipulate the video image itself) is to place a
shaped window on top of the video window. The window's shape
should correspond to your drawn lines. For more information,
see "man XShapeCombineMask".

If you only need a single color, then you could set the shaped
window's background color to your desired graphic color. As
you change the shape of the window, X will redraw new pixels
of the shape window in the "background" color, so your lines
will appear. If necessary Xv will replace any erased pixels
with the Xv key color, to reveal parts of the video image.

I've never done this myself, so I don't know how fast it would
be. I suspect that drawing on the Xv window itself would be
faster, but that won't always work.

(Some video cards use a color-keyed mask, for example replacing
all blue pixels with parts of the video image. Others use the
video image as a texture and then have their 3D accelerator use
it to draw a textured rectangle.)

This will probably work better if you set the video window's
background color to its color key. If the Xvideo driver has
an attribute associated with the XV_COLORKEY atom, then you
should use the value of that attribute as the background color
of the video window. The reason: X redraws the newly exposed
parts of the video window in the background color immediately.
Xvideo itself would redraw the exposed parts of the window
using the color key eventually, but first X would need to send
an Expose event, your application would need to supply a new
video frame, Xv would need to add drawing commands to the X
request queue, the queue would need to be flushed, and X would
need to handle the drawing requests. That can be slow enough
for your moving lines and rectangles to leave trails behind
them. Having X redraw immediately is better.

If all you need is an opaque rectangle with graphics & text
drawn inside it, then you should probably create an ordinary
rectangular window inside the video window, and draw inside
that. No shapes, no surprises.

I hope this helps... or at least provokes a response from
somebody who knows more about Xv than I do.

Måns Rullgård

unread,
Apr 5, 2003, 3:29:22 PM4/5/03
to
Steve Kirkendall <skirk...@dsl-only.net> writes:

Some Xv drivers have an "XV_AUTOPAINT_COLORKEY" atom. It should be
rather obvious what it does. If set, the color key will be drawn at
the next putimage call. If you want to draw things yourself,
replacing the color key, you'll have set that attribute to 0.

--
Måns Rullgård
m...@users.sf.net

Alex

unread,
Apr 7, 2003, 10:41:55 AM4/7/03
to
Thanx for your anwser.

> I'm no expert, but I have used Xv in a visualization plugin for
> XMMS, to display animation in the root window underneath any
> application windows. I'll take a shot at this.

What is XMMS?

> see "man XShapeCombineMask".
"This manual pages needs a lot more work." :(
So I don't really know how to use it, but I'll try to find some examples.

> If you only need a single color, then you could set the shaped
> window's background color to your desired graphic color.

I use different colors, but I can use the backgroundpixmap instead
(I do that already) to show the right colors.


> I've never done this myself, so I don't know how fast it would
> be. I suspect that drawing on the Xv window itself would be
> faster, but that won't always work.

What did you use in XMMS?


> (Some video cards use a color-keyed mask, for example replacing
> all blue pixels with parts of the video image. Others use the
> video image as a texture and then have their 3D accelerator use
> it to draw a textured rectangle.)

Yes I've heard about it and I read in the manual of my framegrabber
(Arvoo) that it is not supported by its driver.

>
> This will probably work better if you set the video window's
> background color to its color key. If the Xvideo driver has
> an attribute associated with the XV_COLORKEY atom, then you
> should use the value of that attribute as the background color
> of the video window. The reason: X redraws the newly exposed
> parts of the video window in the background color immediately.
> Xvideo itself would redraw the exposed parts of the window
> using the color key eventually, but first X would need to send
> an Expose event, your application would need to supply a new
> video frame, Xv would need to add drawing commands to the X
> request queue, the queue would need to be flushed, and X would
> need to handle the drawing requests. That can be slow enough
> for your moving lines and rectangles to leave trails behind
> them. Having X redraw immediately is better.

So this is not an (good) option?

>
> If all you need is an opaque rectangle with graphics & text
> drawn inside it, then you should probably create an ordinary
> rectangular window inside the video window, and draw inside
> that. No shapes, no surprises.

I need real shapes and lines (there must be drawn not straight lines too).

>
> I hope this helps... or at least provokes a response from
> somebody who knows more about Xv than I do.

Yes it surely helped, because I was really stuck and thought that
expanding XVideo was the only solution.

Alex

unread,
Apr 11, 2003, 1:06:05 PM4/11/03
to
Ok, it works very good with the XShapeCombineMask (I figured it out
:). But we now do have another problem:
When I use the shapemask with two different videowindows (they come
from a different framegrabber and they share the same topwindow) then
the result is like 'random' pixels. Maybe anyone can help?
thanks in adv.
Alex

mmd7...@gmail.com

unread,
May 6, 2020, 5:27:32 PM5/6/20
to
Xvideos
0 new messages