Re: [V4L] bttv: Scaling and Cropping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



You can fix any black "borders" generated by bttv by blocking them with clip
rects.  Assume (worst case) the card generates the following borders: left = 7,
top = 4, right = 4, bottom = 0.  This is the case for NTSC; it may be different
e.g. for PAL.  Take your original desired  rectangle of video and make it larger
by that amount on each of the 4 edges.  Then make the left edge be on a 4-pixel
boundary, and make the width be a multiple of 4.  Also make the height a multiple
of 4.  Now set that rectangle / size as the video size, along with 4 clipping
rectangles that block the areas expanded, outside the original desired rectangle.

Assume the original desired rect is (oleft, otop, oright, obottom) - 4 integer
"non-inclusive" values, e.g. the width of the rect = oright - oleft.  To generate
the rect (left, top, right, bottom) to be set into v4l:

int w = oright - oleft;
int h = obottom - otop;
top = otop - 4;
bottom = (otop + h + 3) & ~3;
left = (oleft - 7) & ~3;
right = (w + oleft) & ~3;

Set the rect (left, top, right, bottom) into v4l (width = right - left, height =
bottom - top), blocking the difference between that rect and the "o" values with
4 clip rectangles - or paint those in a bitmap, e.g. using X draw commands and
XGetImage and set the bitmap.

I think the above is about right; it's derived from larger code I wrote that does
work correctly.  In generalized code you also need to worry about clipping to the
edge of the screen and not exceeding the min and max size (32x32, 640x480 for
NTSC) for the rect set into v4l.

Peter Kaczowka
Ucentric Systems LLC


Trent Piepho wrote:

> On Wed, 15 Nov 2000, Alan Cox wrote:
> > > I would like to use the scaling and cropping features in the bt848
> > > chipset. Are there any ioctls etc in the linux driver to allow me to do
> > > that (by setting the hscale/hactive register etc?).
> >
> > Define the display window the size you want the image. The driver wil scale
> > it to that size for you providing the hardware can do it
>
> For the bt848, and most other capture chips too, you can control the
> horizontal and vertical position of the image within the window.  You can also
> control the horizontal scale of the image, without changing the number of
> pixels.  The number of scan lines is more fixed, as you don't have to deal
> with the imprecise timing of the horizontal section of the scan line.  If you
> ask for 480 active scan lines, you get should 480 lines.  Ask for 640 active
> pixels, you might get 635 active pixels and 5 inactive pixels.
>
> For instance, the NTSC hscale/hactive values in the bttv's tvnorms table are
> wrong.  They're not the same as in the datasheet, and result in a black band
> on the left because the front porch isn't long enough.
>
> Even if they're fixed to the correct values, there is still fine tuning than
> can be done, but it's not some fixed amount.  Even on the same channel, the
> exact position and timing of the signal changes between commercials.
>
> Unfortunately, V4L has no concept of these things, which is one of the larger
> omissions IMHO.  I added two BTTV specific ioctl's for reading the writing the
> bt848 control registers, and then added timing parameter tuning controls, like
> the position/size controls on a monitor, to my TV program.
>
> _______________________________________________
> Video4linux-list mailing list
> Video4linux-list@xxxxxxxxxx
> https://listman.redhat.com/mailman/listinfo/video4linux-list





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux