Merge commit 'fa8fcab1e0d31074c0644c4ac5194474c6c26415'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 1 Nov 2012 11:53:19 +0000 (12:53 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 1 Nov 2012 12:11:51 +0000 (13:11 +0100)
* commit 'fa8fcab1e0d31074c0644c4ac5194474c6c26415':
  x86: h264_chromamc_10bit: drop pointless PAVG %define
  x86: mmx2 ---> mmxext in function names
  swscale: do not forget to swap data in formats with different endianness

Conflicts:
libavcodec/x86/dsputil_mmx.c
libavfilter/x86/gradfun.c
libswscale/input.c
libswscale/utils.c
libswscale/x86/swscale.c
tests/ref/lavfi/pixfmts_scale

Merged-by: Michael Niedermayer <michaelni@gmx.at>
23 files changed:
1  2 
libavcodec/dct-test.c
libavcodec/dsputil.h
libavcodec/x86/cavsdsp.c
libavcodec/x86/diracdsp_mmx.c
libavcodec/x86/diracdsp_mmx.h
libavcodec/x86/dsputil_mmx.c
libavcodec/x86/dsputil_mmx.h
libavcodec/x86/dsputilenc_mmx.c
libavcodec/x86/fdct.c
libavcodec/x86/h264_qpel.c
libavcodec/x86/h264dsp_init.c
libavcodec/x86/idct_mmx_xvid.c
libavcodec/x86/idct_xvid.h
libavcodec/x86/motion_est.c
libavcodec/x86/mpegvideoenc.c
libavcodec/x86/vc1dsp_mmx.c
libavfilter/x86/gradfun.c
libavfilter/x86/yadif.c
libswscale/input.c
libswscale/utils.c
libswscale/x86/rgb2rgb.c
libswscale/x86/swscale.c
libswscale/x86/yuv2rgb.c

@@@ -125,17 -105,10 +125,17 @@@ static const struct algo idct_tab[] = 
      { "SIMPLE-C",       ff_simple_idct_8,      NO_PERM  },
  
  #if HAVE_MMX_INLINE
 +#if CONFIG_GPL
 +    { "LIBMPEG2-MMX",   ff_mmx_idct,           MMX_PERM,  AV_CPU_FLAG_MMX,  1 },
 +    { "LIBMPEG2-MMX2",  ff_mmxext_idct,        MMX_PERM,  AV_CPU_FLAG_MMX2, 1 },
 +#endif
      { "SIMPLE-MMX",     ff_simple_idct_mmx,  MMX_SIMPLE_PERM, AV_CPU_FLAG_MMX },
      { "XVID-MMX",       ff_idct_xvid_mmx,      NO_PERM,   AV_CPU_FLAG_MMX,  1 },
-     { "XVID-MMXEXT",    ff_idct_xvid_mmx2,     NO_PERM,   AV_CPU_FLAG_MMXEXT, 1 },
+     { "XVID-MMXEXT",    ff_idct_xvid_mmxext,   NO_PERM,   AV_CPU_FLAG_MMXEXT, 1 },
      { "XVID-SSE2",      ff_idct_xvid_sse2,     SSE2_PERM, AV_CPU_FLAG_SSE2, 1 },
 +#if ARCH_X86_64 && HAVE_YASM
 +    { "PR-SSE2",        ff_prores_idct_put_10_sse2_wrap,     TRANSPOSE_PERM, AV_CPU_FLAG_SSE2, 1 },
 +#endif
  #endif
  
  #if ARCH_BFIN
Simple merge
Simple merge
index 2a040da,0000000..ee89295
mode 100644,000000..100644
--- /dev/null
@@@ -1,101 -1,0 +1,101 @@@
-         PIXFUNC(avg, 0, mmx2);
 +/*
 + * Copyright (C) 2010 David Conrad
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#include "dsputil_mmx.h"
 +#include "diracdsp_mmx.h"
 +
 +void ff_put_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
 +void ff_put_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
 +void ff_put_signed_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
 +void ff_put_signed_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
 +
 +#define HPEL_FILTER(MMSIZE, EXT)                                                             \
 +    void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *, const uint8_t *, int, int);               \
 +    void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, const uint8_t *, int);                    \
 +                                                                                             \
 +    static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc,       \
 +                                          const uint8_t *src, int stride, int width, int height)   \
 +    {                                                                                        \
 +        while( height-- )                                                                    \
 +        {                                                                                    \
 +            ff_dirac_hpel_filter_v_ ## EXT(dstv-MMSIZE, src-MMSIZE, stride, width+MMSIZE+5); \
 +            ff_dirac_hpel_filter_h_ ## EXT(dsth, src, width);                                \
 +            ff_dirac_hpel_filter_h_ ## EXT(dstc, dstv, width);                               \
 +                                                                                             \
 +            dsth += stride;                                                                  \
 +            dstv += stride;                                                                  \
 +            dstc += stride;                                                                  \
 +            src  += stride;                                                                  \
 +        }                                                                                    \
 +    }
 +
 +#if !ARCH_X86_64
 +HPEL_FILTER(8, mmx)
 +#endif
 +HPEL_FILTER(16, sse2)
 +
 +#define PIXFUNC(PFX, IDX, EXT)                                                   \
 +    /*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = ff_ ## PFX ## _dirac_pixels8_ ## EXT;*/  \
 +    c->PFX ## _dirac_pixels_tab[1][IDX] = ff_ ## PFX ## _dirac_pixels16_ ## EXT; \
 +    c->PFX ## _dirac_pixels_tab[2][IDX] = ff_ ## PFX ## _dirac_pixels32_ ## EXT
 +
 +void ff_diracdsp_init_mmx(DiracDSPContext* c)
 +{
 +    int mm_flags = av_get_cpu_flags();
 +
 +#if HAVE_YASM
 +    c->add_dirac_obmc[0] = ff_add_dirac_obmc8_mmx;
 +#if !ARCH_X86_64
 +    c->add_dirac_obmc[1] = ff_add_dirac_obmc16_mmx;
 +    c->add_dirac_obmc[2] = ff_add_dirac_obmc32_mmx;
 +    c->dirac_hpel_filter = dirac_hpel_filter_mmx;
 +    c->add_rect_clamped = ff_add_rect_clamped_mmx;
 +    c->put_signed_rect_clamped = ff_put_signed_rect_clamped_mmx;
 +#endif
 +#endif
 +
 +#if HAVE_MMX_INLINE
 +    PIXFUNC(put, 0, mmx);
 +    PIXFUNC(avg, 0, mmx);
 +#endif
 +
 +#if HAVE_MMXEXT_INLINE
 +    if (mm_flags & AV_CPU_FLAG_MMX2) {
++        PIXFUNC(avg, 0, mmxext);
 +    }
 +#endif
 +
 +    if (mm_flags & AV_CPU_FLAG_SSE2) {
 +#if HAVE_YASM
 +        c->dirac_hpel_filter = dirac_hpel_filter_sse2;
 +        c->add_rect_clamped = ff_add_rect_clamped_sse2;
 +        c->put_signed_rect_clamped = ff_put_signed_rect_clamped_sse2;
 +
 +        c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2;
 +        c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2;
 +#endif
 +#if HAVE_SSE2_INLINE
 +        c->put_dirac_pixels_tab[1][0] = ff_put_dirac_pixels16_sse2;
 +        c->avg_dirac_pixels_tab[1][0] = ff_avg_dirac_pixels16_sse2;
 +        c->put_dirac_pixels_tab[2][0] = ff_put_dirac_pixels32_sse2;
 +        c->avg_dirac_pixels_tab[2][0] = ff_avg_dirac_pixels32_sse2;
 +#endif
 +    }
 +}
index 3d8e117,0000000..8985854
mode 100644,000000..100644
--- /dev/null
@@@ -1,47 -1,0 +1,47 @@@
- DECL_DIRAC_PIXOP(avg, mmx2);
 +/*
 + * Copyright (c) 2010 David Conrad
 + *
 + * This file is part of FFmpeg.
 + *
 + * FFmpeg is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * FFmpeg is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with FFmpeg; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 + */
 +
 +#ifndef AVCODEC_X86_DIRACDSP_H
 +#define AVCODEC_X86_DIRACDSP_H
 +
 +#include "libavcodec/diracdsp.h"
 +
 +void ff_diracdsp_init_mmx(DiracDSPContext* c);
 +
 +DECL_DIRAC_PIXOP(put, mmx);
 +DECL_DIRAC_PIXOP(avg, mmx);
++DECL_DIRAC_PIXOP(avg, mmxext);
 +
 +void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
 +void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
 +void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
 +void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
 +
 +void ff_add_rect_clamped_mmx(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
 +void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
 +
 +void ff_add_dirac_obmc8_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
 +void ff_add_dirac_obmc16_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
 +void ff_add_dirac_obmc32_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
 +
 +void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
 +void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
 +
 +#endif
@@@ -2180,122 -2116,12 +2180,122 @@@ void ff_put_vc1_mspel_mc00_mmx(uint8_t 
      put_pixels8_mmx(dst, src, stride, 8);
  }
  
- void ff_avg_vc1_mspel_mc00_mmx2(uint8_t *dst, const uint8_t *src,
-                                 int stride, int rnd)
+ void ff_avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src,
+                                   int stride, int rnd)
  {
-     avg_pixels8_mmx2(dst, src, stride, 8);
+     avg_pixels8_mmxext(dst, src, stride, 8);
  }
  
- DIRAC_PIXOP(avg, mmx2)
 +/* only used in VP3/5/6 */
 +static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h)
 +{
 +//    START_TIMER
 +    MOVQ_BFE(mm6);
 +    __asm__ volatile(
 +        "1:                             \n\t"
 +        "movq   (%1), %%mm0             \n\t"
 +        "movq   (%2), %%mm1             \n\t"
 +        "movq   (%1,%4), %%mm2          \n\t"
 +        "movq   (%2,%4), %%mm3          \n\t"
 +        PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
 +        "movq   %%mm4, (%3)             \n\t"
 +        "movq   %%mm5, (%3,%4)          \n\t"
 +
 +        "movq   (%1,%4,2), %%mm0        \n\t"
 +        "movq   (%2,%4,2), %%mm1        \n\t"
 +        "movq   (%1,%5), %%mm2          \n\t"
 +        "movq   (%2,%5), %%mm3          \n\t"
 +        "lea    (%1,%4,4), %1           \n\t"
 +        "lea    (%2,%4,4), %2           \n\t"
 +        PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4,   %%mm2, %%mm3, %%mm5)
 +        "movq   %%mm4, (%3,%4,2)        \n\t"
 +        "movq   %%mm5, (%3,%5)          \n\t"
 +        "lea    (%3,%4,4), %3           \n\t"
 +        "subl   $4, %0                  \n\t"
 +        "jnz    1b                      \n\t"
 +        :"+r"(h), "+r"(a), "+r"(b), "+r"(dst)
 +        :"r"((x86_reg)stride), "r"((x86_reg)3L*stride)
 +        :"memory");
 +//    STOP_TIMER("put_vp_no_rnd_pixels8_l2_mmx")
 +}
 +static void put_vp_no_rnd_pixels16_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h)
 +{
 +    put_vp_no_rnd_pixels8_l2_mmx(dst, a, b, stride, h);
 +    put_vp_no_rnd_pixels8_l2_mmx(dst+8, a+8, b+8, stride, h);
 +}
 +
 +#if CONFIG_DIRAC_DECODER
 +#define DIRAC_PIXOP(OPNAME, EXT)\
 +void ff_ ## OPNAME ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
 +{\
 +    OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\
 +}\
 +void ff_ ## OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
 +{\
 +    OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
 +}\
 +void ff_ ## OPNAME ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
 +{\
 +    OPNAME ## _pixels16_ ## EXT(dst   , src[0]   , stride, h);\
 +    OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
 +}
 +
 +DIRAC_PIXOP(put, mmx)
 +DIRAC_PIXOP(avg, mmx)
++DIRAC_PIXOP(avg, mmxext)
 +
 +void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
 +{
 +    put_pixels16_sse2(dst, src[0], stride, h);
 +}
 +void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
 +{
 +    avg_pixels16_sse2(dst, src[0], stride, h);
 +}
 +void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
 +{
 +    put_pixels16_sse2(dst   , src[0]   , stride, h);
 +    put_pixels16_sse2(dst+16, src[0]+16, stride, h);
 +}
 +void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
 +{
 +    avg_pixels16_sse2(dst   , src[0]   , stride, h);
 +    avg_pixels16_sse2(dst+16, src[0]+16, stride, h);
 +}
 +#endif
 +
 +/* XXX: Those functions should be suppressed ASAP when all IDCTs are
 + * converted. */
 +#if CONFIG_GPL
 +static void ff_libmpeg2mmx_idct_put(uint8_t *dest, int line_size,
 +                                    DCTELEM *block)
 +{
 +    ff_mmx_idct(block);
 +    ff_put_pixels_clamped_mmx(block, dest, line_size);
 +}
 +
 +static void ff_libmpeg2mmx_idct_add(uint8_t *dest, int line_size,
 +                                    DCTELEM *block)
 +{
 +    ff_mmx_idct(block);
 +    ff_add_pixels_clamped_mmx(block, dest, line_size);
 +}
 +
 +static void ff_libmpeg2mmx2_idct_put(uint8_t *dest, int line_size,
 +                                     DCTELEM *block)
 +{
 +    ff_mmxext_idct(block);
 +    ff_put_pixels_clamped_mmx(block, dest, line_size);
 +}
 +
 +static void ff_libmpeg2mmx2_idct_add(uint8_t *dest, int line_size,
 +                                     DCTELEM *block)
 +{
 +    ff_mmxext_idct(block);
 +    ff_add_pixels_clamped_mmx(block, dest, line_size);
 +}
 +#endif
 +
  static void vorbis_inverse_coupling_3dnow(float *mag, float *ang, int blocksize)
  {
      int i;
@@@ -2657,10 -2493,16 +2657,10 @@@ static void dsputil_init_mmxext(DSPCont
          }
      }
  
 -    if (!high_bit_depth && avctx->idct_algo == FF_IDCT_XVIDMMX) {
 -        c->idct_put = ff_idct_xvid_mmxext_put;
 -        c->idct_add = ff_idct_xvid_mmxext_add;
 -        c->idct     = ff_idct_xvid_mmxext;
 -    }
 -
      if (CONFIG_VP3_DECODER && (avctx->codec_id == AV_CODEC_ID_VP3 ||
                                 avctx->codec_id == AV_CODEC_ID_THEORA)) {
-         c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_exact_mmx2;
-         c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_exact_mmx2;
+         c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_exact_mmxext;
+         c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_exact_mmxext;
      }
  #endif /* HAVE_INLINE_ASM */
  
@@@ -3011,53 -2857,11 +3011,53 @@@ void ff_dsputil_init_mmx(DSPContext *c
          c->add_hfyu_median_prediction = add_hfyu_median_prediction_cmov;
  #endif
  
 -    if (mm_flags & AV_CPU_FLAG_MMX)
 +    if (mm_flags & AV_CPU_FLAG_MMX) {
 +#if HAVE_INLINE_ASM
 +        const int idct_algo = avctx->idct_algo;
 +
 +        if (avctx->lowres == 0 && avctx->bits_per_raw_sample <= 8) {
 +            if (idct_algo == FF_IDCT_AUTO || idct_algo == FF_IDCT_SIMPLEMMX) {
 +                c->idct_put              = ff_simple_idct_put_mmx;
 +                c->idct_add              = ff_simple_idct_add_mmx;
 +                c->idct                  = ff_simple_idct_mmx;
 +                c->idct_permutation_type = FF_SIMPLE_IDCT_PERM;
 +#if CONFIG_GPL
 +            } else if (idct_algo == FF_IDCT_LIBMPEG2MMX) {
 +                if (mm_flags & AV_CPU_FLAG_MMX2) {
 +                    c->idct_put = ff_libmpeg2mmx2_idct_put;
 +                    c->idct_add = ff_libmpeg2mmx2_idct_add;
 +                    c->idct     = ff_mmxext_idct;
 +                } else {
 +                    c->idct_put = ff_libmpeg2mmx_idct_put;
 +                    c->idct_add = ff_libmpeg2mmx_idct_add;
 +                    c->idct     = ff_mmx_idct;
 +                }
 +                c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
 +#endif
 +            } else if (idct_algo == FF_IDCT_XVIDMMX) {
 +                if (mm_flags & AV_CPU_FLAG_SSE2) {
 +                    c->idct_put              = ff_idct_xvid_sse2_put;
 +                    c->idct_add              = ff_idct_xvid_sse2_add;
 +                    c->idct                  = ff_idct_xvid_sse2;
 +                    c->idct_permutation_type = FF_SSE2_IDCT_PERM;
 +                } else if (mm_flags & AV_CPU_FLAG_MMXEXT) {
-                     c->idct_put              = ff_idct_xvid_mmx2_put;
-                     c->idct_add              = ff_idct_xvid_mmx2_add;
-                     c->idct                  = ff_idct_xvid_mmx2;
++                    c->idct_put              = ff_idct_xvid_mmxext_put;
++                    c->idct_add              = ff_idct_xvid_mmxext_add;
++                    c->idct                  = ff_idct_xvid_mmxext;
 +                } else {
 +                    c->idct_put              = ff_idct_xvid_mmx_put;
 +                    c->idct_add              = ff_idct_xvid_mmx_add;
 +                    c->idct                  = ff_idct_xvid_mmx;
 +                }
 +            }
 +        }
 +#endif /* HAVE_INLINE_ASM */
 +
          dsputil_init_mmx(c, avctx, mm_flags);
 +    }
  
      if (mm_flags & AV_CPU_FLAG_MMXEXT)
-         dsputil_init_mmx2(c, avctx, mm_flags);
+         dsputil_init_mmxext(c, avctx, mm_flags);
  
      if (mm_flags & AV_CPU_FLAG_3DNOW)
          dsputil_init_3dnow(c, avctx, mm_flags);
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -128,10 -128,10 +128,10 @@@ LF_IFUNC(v, chroma_intra, depth, avx
  LF_FUNCS(uint8_t,   8)
  LF_FUNCS(uint16_t, 10)
  
 -#if ARCH_X86_32
 +#if ARCH_X86_32 && HAVE_YASM
  LF_FUNC(v8, luma, 8, mmx2)
- static void ff_deblock_v_luma_8_mmx2(uint8_t *pix, int stride, int alpha,
-                                      int beta, int8_t *tc0)
+ static void ff_deblock_v_luma_8_mmxext(uint8_t *pix, int stride, int alpha,
+                                        int beta, int8_t *tc0)
  {
      if ((tc0[0] & tc0[1]) >= 0)
          ff_deblock_v8_luma_8_mmx2(pix + 0, stride, alpha, beta, tc0);
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -30,7 -30,9 +30,9 @@@ DECLARE_ALIGNED(16, static const uint16
  DECLARE_ALIGNED(16, static const uint16_t, pw_ff)[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
  
  #if HAVE_MMXEXT_INLINE
- static void gradfun_filter_line_mmx2(uint8_t *dst, const uint8_t *src, const uint16_t *dc, int width, int thresh, const uint16_t *dithers)
 -static void gradfun_filter_line_mmxext(uint8_t *dst, uint8_t *src, uint16_t *dc,
++static void gradfun_filter_line_mmxext(uint8_t *dst, const uint8_t *src, const uint16_t *dc,
+                                        int width, int thresh,
+                                        const uint16_t *dithers)
  {
      intptr_t x;
      if (width & 3) {
Simple merge
@@@ -927,15 -721,9 +927,16 @@@ av_cold void ff_sws_init_input_funcs(Sw
      case AV_PIX_FMT_YUV422P10LE:
      case AV_PIX_FMT_YUV444P10LE:
      case AV_PIX_FMT_YUV420P10LE:
 +    case AV_PIX_FMT_YUV422P12LE:
 +    case AV_PIX_FMT_YUV444P12LE:
 +    case AV_PIX_FMT_YUV420P12LE:
 +    case AV_PIX_FMT_YUV422P14LE:
 +    case AV_PIX_FMT_YUV444P14LE:
 +    case AV_PIX_FMT_YUV420P14LE:
      case AV_PIX_FMT_YUV420P16LE:
      case AV_PIX_FMT_YUV422P16LE:
+     case AV_PIX_FMT_YUV444P16LE:
 +
      case AV_PIX_FMT_YUVA444P9LE:
      case AV_PIX_FMT_YUVA422P9LE:
      case AV_PIX_FMT_YUVA420P9LE:
      case AV_PIX_FMT_YUV420P16LE:
      case AV_PIX_FMT_YUV422P16LE:
      case AV_PIX_FMT_YUV444P16LE:
 +
+     case AV_PIX_FMT_GRAY16LE:
+         c->lumToYV12 = bswap16Y_c;
+         break;
      case AV_PIX_FMT_YUVA444P9LE:
      case AV_PIX_FMT_YUVA422P9LE:
      case AV_PIX_FMT_YUVA420P9LE:
      case AV_PIX_FMT_YUV420P16BE:
      case AV_PIX_FMT_YUV422P16BE:
      case AV_PIX_FMT_YUV444P16BE:
 +
+     case AV_PIX_FMT_GRAY16BE:
+         c->lumToYV12 = bswap16Y_c;
+         break;
      case AV_PIX_FMT_YUVA444P9BE:
      case AV_PIX_FMT_YUVA422P9BE:
      case AV_PIX_FMT_YUVA420P9BE:
@@@ -1150,10 -1079,10 +1151,10 @@@ av_cold int sws_init_context(SwsContex
              FF_ALLOCZ_OR_GOTO(c, c->hLumFilterPos, (dstW       / 2 / 8 + 8) * sizeof(int32_t), fail);
              FF_ALLOCZ_OR_GOTO(c, c->hChrFilterPos, (c->chrDstW / 2 / 4 + 8) * sizeof(int32_t), fail);
  
-             initMMX2HScaler(      dstW, c->lumXInc, c->lumMmxextFilterCode,
-                             c->hLumFilter, (uint32_t*)c->hLumFilterPos, 8);
-             initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmxextFilterCode,
-                             c->hChrFilter, (uint32_t*)c->hChrFilterPos, 4);
 -            init_hscaler_mmxext(dstW, c->lumXInc, c->lumMmxextFilterCode,
 -                                c->hLumFilter, c->hLumFilterPos, 8);
++            init_hscaler_mmxext(      dstW, c->lumXInc, c->lumMmxextFilterCode,
++                                c->hLumFilter, (uint32_t*)c->hLumFilterPos, 8);
+             init_hscaler_mmxext(c->chrDstW, c->chrXInc, c->chrMmxextFilterCode,
 -                                c->hChrFilter, c->hChrFilterPos, 4);
++                                c->hChrFilter, (uint32_t*)c->hChrFilterPos, 4);
  
  #if USE_MMAP
              mprotect(c->lumMmxextFilterCode, c->lumMmxextFilterCodeSize, PROT_EXEC | PROT_READ);
Simple merge
@@@ -205,67 -203,6 +205,67 @@@ void updateMMXDitherTables(SwsContext *
      }
  }
  
-         return yuv2yuvX_MMX2(filter, filterSize, src, dest, dstW, dither, offset);
 +#if HAVE_MMXEXT
 +static void yuv2yuvX_sse3(const int16_t *filter, int filterSize,
 +                           const int16_t **src, uint8_t *dest, int dstW,
 +                           const uint8_t *dither, int offset)
 +{
 +    if(((int)dest) & 15){
++        return yuv2yuvX_MMXEXT(filter, filterSize, src, dest, dstW, dither, offset);
 +    }
 +    if (offset) {
 +        __asm__ volatile("movq       (%0), %%xmm3\n\t"
 +                         "movdqa    %%xmm3, %%xmm4\n\t"
 +                         "psrlq       $24, %%xmm3\n\t"
 +                         "psllq       $40, %%xmm4\n\t"
 +                         "por       %%xmm4, %%xmm3\n\t"
 +                         :: "r"(dither)
 +                         );
 +    } else {
 +        __asm__ volatile("movq       (%0), %%xmm3\n\t"
 +                         :: "r"(dither)
 +                         );
 +    }
 +    __asm__ volatile(
 +        "pxor      %%xmm0, %%xmm0\n\t"
 +        "punpcklbw %%xmm0, %%xmm3\n\t"
 +        "psraw        $4, %%xmm3\n\t"
 +        "movdqa    %%xmm3, %%xmm4\n\t"
 +        "movdqa    %%xmm3, %%xmm7\n\t"
 +        "movl %3, %%ecx\n\t"
 +        "mov                                 %0, %%"REG_d"  \n\t"\
 +        "mov                        (%%"REG_d"), %%"REG_S"  \n\t"\
 +        ".p2align                             4             \n\t" /* FIXME Unroll? */\
 +        "1:                                                 \n\t"\
 +        "movddup                  8(%%"REG_d"), %%xmm0      \n\t" /* filterCoeff */\
 +        "movdqa              (%%"REG_S", %%"REG_c", 2), %%xmm2      \n\t" /* srcData */\
 +        "movdqa            16(%%"REG_S", %%"REG_c", 2), %%xmm5      \n\t" /* srcData */\
 +        "add                                $16, %%"REG_d"  \n\t"\
 +        "mov                        (%%"REG_d"), %%"REG_S"  \n\t"\
 +        "test                         %%"REG_S", %%"REG_S"  \n\t"\
 +        "pmulhw                           %%xmm0, %%xmm2      \n\t"\
 +        "pmulhw                           %%xmm0, %%xmm5      \n\t"\
 +        "paddw                            %%xmm2, %%xmm3      \n\t"\
 +        "paddw                            %%xmm5, %%xmm4      \n\t"\
 +        " jnz                                1b             \n\t"\
 +        "psraw                               $3, %%xmm3      \n\t"\
 +        "psraw                               $3, %%xmm4      \n\t"\
 +        "packuswb                         %%xmm4, %%xmm3      \n\t"
 +        "movntdq                          %%xmm3, (%1, %%"REG_c")\n\t"
 +        "add                         $16, %%"REG_c"         \n\t"\
 +        "cmp                          %2, %%"REG_c"         \n\t"\
 +        "movdqa    %%xmm7, %%xmm3\n\t"
 +        "movdqa    %%xmm7, %%xmm4\n\t"
 +        "mov                                 %0, %%"REG_d"  \n\t"\
 +        "mov                        (%%"REG_d"), %%"REG_S"  \n\t"\
 +        "jb                                  1b             \n\t"\
 +        :: "g" (filter),
 +           "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset)
 +        : "%"REG_d, "%"REG_S, "%"REG_c
 +    );
 +}
 +#endif
 +
  #endif /* HAVE_INLINE_ASM */
  
  #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
@@@ -381,11 -311,7 +381,11 @@@ av_cold void ff_sws_init_swScale_mmx(Sw
          sws_init_swScale_MMX(c);
  #if HAVE_MMXEXT_INLINE
      if (cpu_flags & AV_CPU_FLAG_MMXEXT)
-         sws_init_swScale_MMX2(c);
+         sws_init_swScale_MMXEXT(c);
 +    if (cpu_flags & AV_CPU_FLAG_SSE3){
 +        if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND))
 +            c->yuv2planeX = yuv2yuvX_sse3;
 +    }
  #endif
  #endif /* HAVE_INLINE_ASM */
  
Simple merge