[FFmpeg-soc] [PATCH] 3/4 Split sws_getContext_altivec_unscyv2packyuv from sws_getContext

Michael Niedermayer michaelni at gmx.at
Wed Jun 11 06:55:02 CEST 2008


On Wed, Jun 11, 2008 at 02:35:54AM +0200, Keiji Costantini wrote:
> as tradition... forgot to attach patch ^^'
>
> -- 
> Keiji Costantini

> >From 4221a85c04622cf664fdc1e35d30b5194379995e Mon Sep 17 00:00:00 2001
> From: Keiji Costantini <lists at strites.net>
> Date: Wed, 11 Jun 2008 01:49:30 +0200
> Subject: [PATCH] Split sws_getContext_altivec_unscyv2packyuv from sws_getContext
> 
> ---
>  swscale.c |   23 ++++++++++++++---------
>  1 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/swscale.c b/swscale.c
> index 5afd1c5..6e0bd38 100644
> --- a/swscale.c
> +++ b/swscale.c
> @@ -1941,6 +1941,19 @@ static inline void sws_getContext_setcpuflag(int *flags) {
>  #endif
>  }
>  
> +static inline void sws_getContext_altivec_unscyv2packyuv(SwsContext *c, int *srcFormat, int *dstFormat) {
> +    if ((c->flags & SWS_CPU_CAPS_ALTIVEC) &&
> +        ((*srcFormat == PIX_FMT_YUV420P &&
> +         (*dstFormat == PIX_FMT_YUYV422 || dstFormat == PIX_FMT_UYVY422)))) {
> +      // unscaled YV12 -> packed YUV, we want speed
> +      if (*dstFormat == PIX_FMT_YUYV422)
> +          c->swScale= yv12toyuy2_unscaled_altivec;
> +      else
> +          c->swScale= yv12touyvy_unscaled_altivec;
> +    }
> +}
> +
> +
>  SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
>                             SwsFilter *srcFilter, SwsFilter *dstFilter, double *param){
>  
> @@ -2113,15 +2126,7 @@ SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, int dstW, int dstH
>          }
>  
>  #ifdef HAVE_ALTIVEC
> -        if ((c->flags & SWS_CPU_CAPS_ALTIVEC) &&
> -            ((srcFormat == PIX_FMT_YUV420P &&
> -             (dstFormat == PIX_FMT_YUYV422 || dstFormat == PIX_FMT_UYVY422)))) {
> -          // unscaled YV12 -> packed YUV, we want speed
> -          if (dstFormat == PIX_FMT_YUYV422)
> -              c->swScale= yv12toyuy2_unscaled_altivec;
> -          else
> -              c->swScale= yv12touyvy_unscaled_altivec;
> -        }
> +        sws_getContext_altivec_unscyv2packyuv(&c, &srcFormat, &dstFormat);
>  #endif

Moving that into its own function is fine in principle, problem is the
code itself is wrong at several levels
* that block should be under c->flags&(SWS_FAST_BILINEAR|SWS_POINT)
  because it is a crappy low quality converter not matching the generic
  code.
* with that, the code is duplicate of the code above it and can be factored
  out so the altivec check is moved into
  PlanarToYuy2Wrapper/PlanarToUyvyWrapper



[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080611/5c97a167/attachment.pgp>


More information about the FFmpeg-soc mailing list