On Thu, Jun 10, 2004 at 02:56:12PM +0200, Claudio KLaN Ciccani wrote:
> If you don't have objections, I'm going to apply this patch (see below) 
> to DirectFB/src/gfx/generic/generic.c.
> It enables stretchblitting YUV surfaces and requires only small changes.

See my comments below.

<snip>
> @@ -4623,20 +4623,24 @@
> 
>      int f;
>      int i = 0;
> +     int h;
> 
>      D_ASSERT( gfxs != NULL );
> 
>      CHECK_PIPELINE();
> 
> -     gfxs->length = drect->w;
>      gfxs->SperD  = (srect->w << 16) / drect->w;
> +     gfxs->length = drect->w;
> +     if (gfxs->src_format == DSPF_YUY2 || gfxs->src_format == DSPF_UYVY)
> +      gfxs->length /= 2;

This will probably look quite bad. But I suppose it's better than 
nothing...

> 
>      f = (srect->h << 16) / drect->h;
> +     h = drect->h;
> 
>      Aop_xy( gfxs, gfxs->dst_org, drect->x, drect->y, gfxs->dst_pitch );
>      Bop_xy( gfxs, gfxs->src_org, srect->x, srect->y, gfxs->src_pitch );
> 
> -     while (drect->h--) {
> +     while (h--) {
>           RUN_PIPELINE();
> 
>           Aop_next( gfxs, gfxs->dst_pitch );
> @@ -4648,6 +4652,39 @@
>                Bop_next( gfxs, gfxs->src_pitch );
>           }
>      }
> +
> +     /* scale other planes */
> +     if (gfxs->src_format == DSPF_YV12 || gfxs->src_format == DSPF_I420) {
> +      void *splane1 = gfxs->src_org + (gfxs->src_pitch * gfxs->src_height)
> +                      + ((gfxs->src_pitch * srect->y) / 4) + (srect->x 
> / 2);
> +      void *splane2 = splane1 + ((gfxs->src_pitch * gfxs->src_height) / 4);
> +      void *dplane1 = gfxs->dst_org + (gfxs->dst_pitch * gfxs->dst_height)
> +                      + ((gfxs->dst_pitch * drect->y) / 4) + (drect->x 
> / 2);
> +      void *dplane2 = dplane1 + ((gfxs->dst_pitch * gfxs->dst_height) / 4);
> +      int   spitch = gfxs->src_pitch / 2;
> +      int   dpitch = gfxs->dst_pitch / 2;
> +
> +      gfxs->length = drect->w / 2;
> +      h = drect->h / 2;
> +      i = 0;
> +
> +      while (h--) {
> +           gfxs->Bop = splane1 + (i >> 16) * spitch;
> +           gfxs->Aop = dplane1;

You should use ?op_xy() and ?op_next() to do this stuff.

> +
> +           RUN_PIPELINE();
> +
> +           gfxs->Bop = splane2 + (i >> 16) * spitch;
> +           gfxs->Aop = dplane2;
> +
> +           RUN_PIPELINE();
> +
> +           dplane1 += dpitch;
> +           dplane2 += dpitch;

I think blitting the planes one at a time would be better.

> +
> +           i += f;
> +      }
> +     }
> }

-- 
Ville Syrj�l�
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/


Reply via email to