Re: Deinterlacing?

Bj|rn Englund <[email protected]> Wed, 28 Sep 2005 02:40:38 +0200
Newsgroups gmane.comp.video.ogle.devel
Message-ID <[email protected]>
Tue Sep 27 2005, [email protected] wrote:

> Could you point me to some documentation on Xv? I definitely don't
> understand how this works at the point. How you manage to get away with
> the increased width; and, more importantly, why XvPutImage (which actually
> does all the zooming itself, right?) correctly doubles the image height,
> but breaks if it has to zoom to some other size than the original.

The XvCreateImage call sets the image format, normally we set the
width to w and height to h.
When deinterlacing, I set the width to w*2 and height to h/2.
This "moves" odd lines in the normal image to the right of the
even lines (as you said in an earlier email).
Then I just tell XvPutImage to show the left half of the image
(w) (which is the even lines), but the full height (h/2) (which is half
of the lines from the normal image). XvPutImage also takes as parameters
the area you want the source image to be scaled to, and this area is
the same both for normal and deinterlaced pictures.
The problem with the zoom is not in XvPutImage, but in the functions I
have that calculates which source area (part of the xv_image) that XvPutImage
should show. I think the calculations gets screwed up because
the y offsets and height are still based on the size of the normal image
and not the modified height of the deinterlaced one.

I think when you define the rectangle that is to be zoomed to, that
it uses the coordinates of the normal picture. Example:
the rectangle 10,20 -> 50,70, is the source area. This is reported
as x=10 y=20 width=40 height=50
What is done now is that height is divided by 2 which is ok.
But the y offset should also be divided by 2.
So if you add
src_view_area.y = src_view_area.y/2;
at the same place as src_view_area.height/2 is done in the patch
the zoom will work.


> 
> And I also need to know how to deallocate an XvImage - to fix that memory
> leak...
> 
> Google did not help me find any docs :(
> 
There doesn't seem to be much docs on Xv.
Maybe the best place to get information is to look at the source code
for XFree/X.org.
For normal XImages there is a XDestroyImage but I don't think/know there is an
XvDestroyImage.

/Bj|rn