On Wed, 2005-05-04 at 14:17 -0400, Daniel Kristjansson wrote:
> BTW I'm working on a bob fix that doesn't break XvMC, I'll probably send
> a patch tonight if my testing goes well.
Attached is a patch that fixes bob displacement for overscan
with XVideo, while letting XvMC still work when there is no
overscan.
It appears the nVidia closed source drivers no longer
require a bob displacement, as of v66.29. Of course, this
is a blessing and a curse, the automatic displacement
means we don't need a displacement normally, but it does
not work at all when we do over/under scan.
I've tried the obvious of applying displacement only in the
overscan or underscan cases, and also the less obvious of
calculating the normal displacement and over/under scan
displacement then applying the difference. Neither worked.
Anyway, I'd like to know if the patch is a regression
for anyone before applying it.
-- Daniel
Index: libs/libmythtv/videoout_xv.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/videoout_xv.cpp,v
retrieving revision 1.138
diff -u -r1.138 videoout_xv.cpp
--- libs/libmythtv/videoout_xv.cpp 4 May 2005 14:47:57 -0000 1.138
+++ libs/libmythtv/videoout_xv.cpp 4 May 2005 19:33:51 -0000
@@ -1848,34 +1848,65 @@
}
static void calc_bob(FrameScanType scan, int imgh, int disphoff,
- int imgy, int dispyoff,
- int frame_height, int top_field_first,
- int &field, int &src_y, int &dest_y)
+ int imgy, int dispyoff,
+ int frame_height, int top_field_first,
+ int &field, int &src_y, int &dest_y,
+ int& xv_src_y_incr, int &xv_dest_y_incr)
{
int dst_half_line_in_src = 0, dest_y_incr = 0, src_y_incr = 0;
+ field = 3;
+ src_y = imgy;
+ dest_y = dispyoff;
+ xv_src_y_incr = 0;
// a negative offset y gives us bobbing, so adjust...
if (dispyoff < 0)
{
dest_y_incr = -dispyoff;
- src_y_incr = (int) (dest_y_incr * imgh * 0.5 / disphoff);
+ src_y_incr = (int) (dest_y_incr * imgh / disphoff);
+ xv_src_y_incr -= (int) (0.5 * dest_y_incr * imgh / disphoff);
}
if ((scan == kScan_Interlaced && top_field_first == 1) ||
(scan == kScan_Intr2ndField && top_field_first == 0))
{
field = 1;
- src_y = imgy / 2;
+ xv_src_y_incr = - imgy / 2;
}
else if ((scan == kScan_Interlaced && top_field_first == 0) ||
(scan == kScan_Intr2ndField && top_field_first == 1))
{
field = 2;
- src_y = (frame_height + imgy) / 2;
- dst_half_line_in_src = (int) round(((float)disphoff)/imgh - 0.001f);
+ xv_src_y_incr += (frame_height - imgy) / 2;
+
+ dst_half_line_in_src =
+ max((int) round((((double)disphoff)/imgh) - 0.00001), 0);
}
+ //if (frame_height>imgh && 2==field)
+ xv_dest_y_incr = dst_half_line_in_src;
+ //else
+ // dest_y += dst_half_line_in_src;
src_y += src_y_incr;
- dest_y += dst_half_line_in_src + dest_y_incr;
+ dest_y += dest_y_incr;
+
+ // DEBUG
+#if 1
+ static int last_dest_y_field[3] = { -1000, -1000, -1000, };
+ int last_dest_y = last_dest_y_field[field];
+
+ if (last_dest_y != dest_y)
+ {
+ cerr<<"####### Field "<<field<<" #######"<<endl;
+ cerr<<" src_y: "<<src_y<<endl;
+ cerr<<" dest_y: "<<dest_y<<endl;
+ cerr<<" xv_src_y_incr: "<<xv_src_y_incr<<endl;
+ cerr<<"xv_dest_y_incr: "<<xv_dest_y_incr<<endl;
+ cerr<<" disphoff: "<<disphoff<<endl;
+ cerr<<" imgh: "<<imgh<<endl;
+ cerr<<endl;
+ }
+ last_dest_y_field[field] = dest_y;
+#endif
}
void VideoOutputXv::ShowXvMC(FrameScanType scan)
@@ -1907,11 +1938,12 @@
// calculate bobbing params
int field = 3, src_y = imgy, dest_y = dispyoff;
+ int xv_src_y_incr = 0, xv_dest_y_incr = 0;
if (m_deinterlacing)
{
calc_bob(scan, imgh, disphoff, imgy, dispyoff,
frame->height, frame->top_field_first,
- field, src_y, dest_y);
+ field, src_y, dest_y, xv_src_y_incr, xv_dest_y_incr);
}
if (hasVLDAcceleration())
{ // don't do bob-adjustment for VLD drivers
@@ -1972,12 +2004,14 @@
return;
}
- int field = 3, src_y = imgy, dest_y = dispyoff;
+ int field = 3, src_y = imgy, dest_y = dispyoff, xv_src_y_incr = 0, xv_dest_y_incr = 0;
if (m_deinterlacing && (m_deintfiltername == "bobdeint"))
{
calc_bob(scan, imgh, disphoff, imgy, dispyoff,
frame->height, frame->top_field_first,
- field, src_y, dest_y);
+ field, src_y, dest_y, xv_src_y_incr, xv_dest_y_incr);
+ src_y += xv_src_y_incr;
+ dest_y += xv_dest_y_incr;
}
vbuffers.UnlockFrame(frame, "ShowXVideo");
@@ -2021,8 +2055,8 @@
*/
void VideoOutputXv::DrawUnusedRects(bool sync)
{
- // boboff assumes the smallest interlaced resolution is 480 lines
- int boboff = (int)round(((float)disphoff) / 480 - 0.001f);
+ // boboff assumes the smallest interlaced resolution is 480 lines - 5%
+ int boboff = (int)round(((double)disphoff) / 456 - 0.00001);
boboff = (m_deinterlacing && m_deintfiltername == "bobdeint") ? boboff : 0;
X11L;
_______________________________________________
mythtv-dev mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev