On Sun, Aug 08, 2004 at 05:01:48PM +0200, Stefan Lucke wrote:
> On Sonntag, 8. August 2004 11:56, Stefan Lucke wrote:
> 
> [ .. ]
> 
> > 
> > Add some trace code to matrox_bes.c and I think cropright values is not correct.
> >  (720x576)area = 90 0 540 576 dest  :(0,32 1280x960)
> > source:(90,0 540x288)
> > crop A:(0,0) (0,0)
> > crop B:(5898240,0) (0,0)
> >  OK !!
> > 0 / 1280; 32 / 1024; 1280 / 1280; 960 / 1024
> > 
> 
> [ .. ]
> 
> I adjusted setting BESHSRCEND to that from X11 mga_video.c (here matrox_bes.c line 
> 585):
> 
>      mbes->regs.besHSRCEND  = ((source.w - 1) << 16) - cropright;
>      mbes->regs.besHSRCEND  = ((source.x+source.w)-0x00010000 - 1)&0x03fffffc;
> 
> With that horizontal scaleing works as expected. But it should be further modified
> to take cropright into account.
> 
> > > 
> > > I just noticed that the matrox code had a bug with vertical cropping. Fix
> > > is already in cvs...
> 
> Vertical scaled crop is still not right. Displayed area is shifted a bit up
> (top black bar is smaller than bottom one) and displayed content is shifted up too.

Does the attached patch fix everything (or even something :) ?

-- 
Ville Syrj�l�
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/
Index: matrox_bes.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox_bes.c,v
retrieving revision 1.50
diff -u -r1.50 matrox_bes.c
--- matrox_bes.c        1 Aug 2004 21:44:18 -0000       1.50
+++ matrox_bes.c        8 Aug 2004 17:22:25 -0000
@@ -449,6 +449,7 @@
      pitch = front_buffer->video.pitch;
 
      if (config->options & DLOP_DEINTERLACING) {
+          source.y /= 2;
           source.h /= 2;
           pitch    *= 2;
      } else
@@ -484,11 +485,6 @@
      if (croptop_uv)
           croptop_uv = ((__u64) ((source.h/2) << 16) * croptop_uv / dest.h) & ~0x3;
 
-     /* add source cropping */
-     cropleft   += config->source.x << 16;
-     croptop    += config->source.y << 16;
-     croptop_uv += (config->source.y/2) << 16;
-
      /* should horizontal zoom be used? */
      if (mdev->g450_matrox)
           hzoom = (1000000/current_mode->pixclock >= 234) ? 1 : 0;
@@ -541,7 +537,7 @@
 
      /* buffer offsets */
      mbes->regs.besA1ORG = front_buffer->video.offset +
-                           pitch * (croptop >> 16);
+                           pitch * (source.y + (croptop >> 16));
      mbes->regs.besA2ORG = mbes->regs.besA1ORG +
                            front_buffer->video.pitch;
 
@@ -549,7 +545,7 @@
           case DSPF_I420:
                mbes->regs.besA1CORG  = front_buffer->video.offset +
                                        surface->height * front_buffer->video.pitch +
-                                       pitch/2 * (croptop_uv >> 16);
+                                       pitch/2 * (source.y/2 + (croptop_uv >> 16));
                mbes->regs.besA2CORG  = mbes->regs.besA1CORG +
                                        front_buffer->video.pitch/2;
 
@@ -562,7 +558,7 @@
           case DSPF_YV12:
                mbes->regs.besA1C3ORG = front_buffer->video.offset +
                                        surface->height * front_buffer->video.pitch +
-                                       pitch/2 * (croptop_uv >> 16);
+                                       pitch/2 * (source.y/2 + (croptop_uv >> 16));
                mbes->regs.besA2C3ORG = mbes->regs.besA1C3ORG +
                                        front_buffer->video.pitch/2;
 
@@ -579,22 +575,22 @@
      mbes->regs.besHCOORD   = (dstBox.x1 << 16) | dstBox.x2;
      mbes->regs.besVCOORD   = (dstBox.y1 << 16) | dstBox.y2;
 
-     mbes->regs.besHSRCST   = cropleft;
-     mbes->regs.besHSRCEND  = ((source.w - 1) << 16) - cropright;
-     mbes->regs.besHSRCLST  = (source.w - 1) << 16;
+     mbes->regs.besHSRCST   = (source.x << 16) + cropleft;
+     mbes->regs.besHSRCEND  = ((source.x + source.w - 1) << 16) - cropright;
+     mbes->regs.besHSRCLST  = (surface->width - 1) << 16;
 
      /* vertical starting weights */
-     tmp = croptop & 0xfffc;
+     tmp = ((source.y << 16) + croptop) & 0xfffc;
      mbes->regs.besV1WGHT = tmp;
      if (tmp >= 0x8000) {
           tmp = tmp - 0x8000;
           /* fields start on the same line */
-          if ((croptop >> 16) & 1)
+          if ((source.y + (croptop >> 16)) & 1)
                mbes->regs.besCTL |= BESV1SRCSTP | BESV2SRCSTP;
      } else {
           tmp = 0x10000 | (0x8000 - tmp);
           /* fields start on alternate lines */
-          if ((croptop >> 16) & 1)
+          if ((source.y + (croptop >> 16)) & 1)
                mbes->regs.besCTL |= BESV1SRCSTP;
           else
                mbes->regs.besCTL |= BESV2SRCSTP;

Reply via email to