Hi,
I'm trying to implement the blitting flag DSBLIT_INTERLACED.
That should be a solution for a 4:3 TVout downscaleing problem.
Discussion first starts here:
http://mail.directfb.org/pipermail/directfb-users/2005-October/000770.html
When forced to do a separate stretchblit for each field, it works.
But for some unkown reason, I could not get SetBlittingFlags(value)
to be passed to matrox driver.
scrSurface->SetBlittingFlags(DSBLIT_INTERLACED);
scrSurface->StretchBlit(videoSurface, &src, &dst);
--
Stefan Lucke
? gfxdrivers/interlaced_blit_01.diff
? gfxdrivers/interlaced_blit_02.diff
? gfxdrivers/ville_03.diff
? tools/dfbpenmount
Index: gfxdrivers/matrox/matrox.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox.c,v
retrieving revision 1.95
diff -U3 -r1.95 matrox.c
--- gfxdrivers/matrox/matrox.c 8 Dec 2005 20:33:04 -0000 1.95
+++ gfxdrivers/matrox/matrox.c 6 May 2006 06:12:54 -0000
@@ -165,6 +165,7 @@
DSBLIT_BLEND_COLORALPHA | \
DSBLIT_COLORIZE | \
DSBLIT_DEINTERLACE | \
+ DSBLIT_INTERLACED | \
DSBLIT_SRC_PREMULTIPLY | \
DSBLIT_SRC_PREMULTCOLOR)
@@ -183,6 +184,7 @@
DSBLIT_BLEND_COLORALPHA | \
DSBLIT_COLORIZE | \
DSBLIT_DEINTERLACE | \
+ DSBLIT_INTERLACED | \
DSBLIT_SRC_PREMULTIPLY | \
DSBLIT_SRC_PREMULTCOLOR) || \
((state)->destination->format != (state)->source->format && \
@@ -444,7 +446,7 @@
case DSPF_YUY2:
if ((accel & DFXL_FILLRECTANGLE && !state->drawingflags) ||
(accel & (DFXL_BLIT | DFXL_STRETCHBLIT) &&
- !(state->blittingflags & ~DSBLIT_DEINTERLACE) &&
+ !(state->blittingflags & ~(DSBLIT_DEINTERLACE | DSBLIT_INTERLACED)) &&
state->source->format == state->destination->format))
break;
return;
@@ -545,7 +547,7 @@
case DSPF_YV12:
if ((accel & DFXL_FILLRECTANGLE && !state->drawingflags) ||
(accel & (DFXL_BLIT | DFXL_STRETCHBLIT) &&
- !(state->blittingflags & ~DSBLIT_DEINTERLACE) &&
+ !(state->blittingflags & ~(DSBLIT_DEINTERLACE | DSBLIT_INTERLACED)) &&
(state->source->format == DSPF_I420 || state->source->format == DSPF_YV12)))
break;
return;
@@ -555,7 +557,7 @@
case DSPF_UYVY:
if ((accel & DFXL_FILLRECTANGLE && !state->drawingflags) ||
(accel & (DFXL_BLIT | DFXL_STRETCHBLIT) &&
- !(state->blittingflags & ~DSBLIT_DEINTERLACE) &&
+ !(state->blittingflags & ~(DSBLIT_DEINTERLACE| DSBLIT_INTERLACED)) &&
state->source->format == state->destination->format))
break;
return;
@@ -736,6 +738,7 @@
mdev->blit_src_colorkey = flags & DSBLIT_SRC_COLORKEY;
mdev->blit_deinterlace = flags & DSBLIT_DEINTERLACE;
+ mdev->blit_interlaced = flags & DSBLIT_INTERLACED;
if (MATROX_USE_TMU( state, accel )) {
if (flags & (DSBLIT_BLEND_COLORALPHA |
@@ -1438,6 +1441,70 @@
}
static inline void
+matroxBlitTMU_interlaced( MatroxDriverData *mdrv,
+ MatroxDeviceData *mdev,
+ DFBRectangle *srect,
+ DFBRectangle *drect,
+ bool filter )
+{
+ volatile __u8 *mmio = mdrv->mmio_base;
+ __u32 texctl;
+
+ texctl = mdev->texctl & ~TPITCHEXT;
+ texctl |= ((mdev->src_pitch*2) << 9) & TPITCHEXT;
+
+ /* field 0 */
+ mga_waitfifo( mdrv, mdev, 5 );
+ mga_out32( mmio, texctl, TEXCTL );
+ mga_out32( mmio, ( (((__u32)(mdev->h/2 - 1) & 0x7ff) << 18) |
+ (((__u32)(4 - (mdev->h2 - 1)) & 0x3f) << 9) |
+ (((__u32)((mdev->h2 - 1) + 4) & 0x3f) ) ), TEXHEIGHT );
+
+ mga_out32( mmio, mdev->src_offset[0], TEXORG );
+ mga_out32( mmio, mdev->dst_pitch*2, PITCH );
+ mga_out32( mmio, mdev->dst_offset[0], DSTORG );
+
+ matroxDoBlitTMU( mdrv, mdev,
+ srect->x, srect->y / 2,
+ drect->x, drect->y / 2,
+ srect->w, srect->h / 2,
+ drect->w, drect->h / 2,
+ mdev->w2, mdev->h2 - 1,
+ filter );
+
+ texctl = mdev->texctl & ~TPITCHEXT;
+ texctl |= ((mdev->src_pitch*2) << 9) & TPITCHEXT;
+
+ /* field 1 */
+ mga_waitfifo( mdrv, mdev, 2 );
+ mga_out32( mmio, mdev->src_offset[0]+mdev->src_stride, TEXORG );
+ mga_out32( mmio, mdev->dst_offset[0]+mdev->dst_stride, DSTORG );
+
+ matroxDoBlitTMU( mdrv, mdev,
+ srect->x, srect->y / 2,
+ drect->x, drect->y / 2,
+ srect->w, srect->h / 2,
+ drect->w, drect->h / 2,
+ mdev->w2, mdev->h2 - 1,
+ filter );
+
+ /* Restore registers */
+ mga_waitfifo( mdrv, mdev, 6 );
+ mga_out32( mmio, mdev->texctl, TEXCTL );
+ mga_out32( mmio, ( (((__u32)(mdev->w - 1) & 0x7ff) << 18) |
+ (((__u32)(4 - mdev->w2) & 0x3f) << 9) |
+ (((__u32)(mdev->w2 + 4) & 0x3f) ) ), TEXWIDTH );
+ mga_out32( mmio, ( (((__u32)(mdev->h - 1) & 0x7ff) << 18) |
+ (((__u32)(4 - mdev->h2) & 0x3f) << 9) |
+ (((__u32)(mdev->h2 + 4) & 0x3f) ) ), TEXHEIGHT );
+ mga_out32( mmio, mdev->src_offset[0], TEXORG );
+
+ mga_out32( mmio, mdev->dst_pitch, PITCH );
+ mga_out32( mmio, mdev->dst_offset[0], DSTORG );
+
+}
+
+static inline void
matroxBlitTMU_2P( MatroxDriverData *mdrv,
MatroxDeviceData *mdev,
DFBRectangle *srect,
@@ -1607,8 +1674,13 @@
MatroxDriverData *mdrv = (MatroxDriverData*) drv;
MatroxDeviceData *mdev = (MatroxDeviceData*) dev;
- matroxBlitTMU( mdrv, mdev, srect, drect, true );
-
+ matroxBlitTMU_interlaced( mdrv, mdev, srect, drect, true );
+#if 0
+ if (mdev->blit_interlaced && !mdev->blit_deinterlace) {
+ matroxBlitTMU_interlaced( mdrv, mdev, srect, drect, true );
+ } else
+ matroxBlitTMU( mdrv, mdev, srect, drect, true );
+#endif
return true;
}
Index: gfxdrivers/matrox/matrox.h
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox.h,v
retrieving revision 1.39
diff -U3 -r1.39 matrox.h
--- gfxdrivers/matrox/matrox.h 8 Dec 2005 20:13:27 -0000 1.39
+++ gfxdrivers/matrox/matrox.h 6 May 2006 06:12:55 -0000
@@ -89,8 +89,10 @@
/* Stored values */
int dst_pitch;
+ int dst_stride;
int dst_offset[3];
int src_pitch;
+ int src_stride;
int src_offset[3];
int w, h, w2, h2;
__u32 color[3];
@@ -100,6 +102,7 @@
bool blit_deinterlace;
int field;
+ bool blit_interlaced;
bool depth_buffer;
Index: gfxdrivers/matrox/matrox_state.c
===================================================================
RCS file: /cvs/directfb/DirectFB/gfxdrivers/matrox/matrox_state.c,v
retrieving revision 1.59
diff -U3 -r1.59 matrox_state.c
--- gfxdrivers/matrox/matrox_state.c 8 Dec 2005 20:33:04 -0000 1.59
+++ gfxdrivers/matrox/matrox_state.c 6 May 2006 06:12:59 -0000
@@ -58,7 +58,8 @@
SurfaceBuffer *depth_buffer = destination->depth_buffer;
int bytes_per_pixel = DFB_BYTES_PER_PIXEL(buffer->format);
- mdev->dst_pitch = buffer->video.pitch / bytes_per_pixel;
+ mdev->dst_pitch = buffer->video.pitch / bytes_per_pixel;
+ mdev->dst_stride = buffer->video.pitch;
D_ASSERT( mdev->dst_pitch % 32 == 0 );
@@ -510,8 +511,9 @@
if (MGA_IS_VALID( m_Source ))
return;
- mdev->src_pitch = buffer->video.pitch / bytes_per_pixel;
- mdev->field = surface->field;
+ mdev->src_pitch = buffer->video.pitch / bytes_per_pixel;
+ mdev->src_stride = buffer->video.pitch;
+ mdev->field = surface->field;
D_ASSERT( mdev->src_pitch % 32 == 0 );
Index: include/directfb.h
===================================================================
RCS file: /cvs/directfb/DirectFB/include/directfb.h,v
retrieving revision 1.285
diff -U3 -r1.285 directfb.h
--- include/directfb.h 6 Apr 2006 12:00:34 -0000 1.285
+++ include/directfb.h 6 May 2006 06:13:10 -0000
@@ -666,8 +666,10 @@
only one field (every second line of full
image) scaling it vertically by factor two */
DSBLIT_SRC_PREMULTCOLOR = 0x00000200, /* modulates the source color with the color alpha */
- DSBLIT_XOR = 0x00000400 /* bitwise xor the destination pixels with the
+ DSBLIT_XOR = 0x00000400, /* bitwise xor the destination pixels with the
source pixels after premultiplication */
+ DSBLIT_INTERLACED = 0x00000800 /* strechblit fields separate when surface
+ is allocated DSCAPS_INTERLACED */
} DFBSurfaceBlittingFlags;
/*
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev