]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/x86/dsputilenc_mmx.c
x86: fft: remove unused fft_dispatch* functions
[ffmpeg] / libavcodec / x86 / dsputilenc_mmx.c
index 1ef5a45ffa569d5459a801d9faf5c88044f2d90c..c0ef0bac3e92ceab9888fba13efc329313c24af2 100644 (file)
@@ -3,39 +3,41 @@
  * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav 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,
+ * Libav 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
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  *
  * MMX optimization by Nick Kurshev <nickols_k@mail.ru>
  */
 
 #include "libavutil/cpu.h"
-#include "libavutil/x86_cpu.h"
+#include "libavutil/x86/asm.h"
 #include "libavcodec/dsputil.h"
 #include "libavcodec/mpegvideo.h"
 #include "libavcodec/mathops.h"
 #include "dsputil_mmx.h"
 
 
+#if HAVE_INLINE_ASM
+
 static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size)
 {
     __asm__ volatile(
         "mov $-128, %%"REG_a"           \n\t"
         "pxor %%mm7, %%mm7              \n\t"
-        ASMALIGN(4)
+        ".p2align 4                     \n\t"
         "1:                             \n\t"
         "movq (%0), %%mm0               \n\t"
         "movq (%0, %2), %%mm2           \n\t"
@@ -61,16 +63,16 @@ static void get_pixels_mmx(DCTELEM *block, const uint8_t *pixels, int line_size)
 static void get_pixels_sse2(DCTELEM *block, const uint8_t *pixels, int line_size)
 {
     __asm__ volatile(
-        "pxor %%xmm7,      %%xmm7         \n\t"
+        "pxor %%xmm4,      %%xmm4         \n\t"
         "movq (%0),        %%xmm0         \n\t"
         "movq (%0, %2),    %%xmm1         \n\t"
         "movq (%0, %2,2),  %%xmm2         \n\t"
         "movq (%0, %3),    %%xmm3         \n\t"
         "lea (%0,%2,4), %0                \n\t"
-        "punpcklbw %%xmm7, %%xmm0         \n\t"
-        "punpcklbw %%xmm7, %%xmm1         \n\t"
-        "punpcklbw %%xmm7, %%xmm2         \n\t"
-        "punpcklbw %%xmm7, %%xmm3         \n\t"
+        "punpcklbw %%xmm4, %%xmm0         \n\t"
+        "punpcklbw %%xmm4, %%xmm1         \n\t"
+        "punpcklbw %%xmm4, %%xmm2         \n\t"
+        "punpcklbw %%xmm4, %%xmm3         \n\t"
         "movdqa %%xmm0,      (%1)         \n\t"
         "movdqa %%xmm1,    16(%1)         \n\t"
         "movdqa %%xmm2,    32(%1)         \n\t"
@@ -79,10 +81,10 @@ static void get_pixels_sse2(DCTELEM *block, const uint8_t *pixels, int line_size
         "movq (%0, %2),    %%xmm1         \n\t"
         "movq (%0, %2,2),  %%xmm2         \n\t"
         "movq (%0, %3),    %%xmm3         \n\t"
-        "punpcklbw %%xmm7, %%xmm0         \n\t"
-        "punpcklbw %%xmm7, %%xmm1         \n\t"
-        "punpcklbw %%xmm7, %%xmm2         \n\t"
-        "punpcklbw %%xmm7, %%xmm3         \n\t"
+        "punpcklbw %%xmm4, %%xmm0         \n\t"
+        "punpcklbw %%xmm4, %%xmm1         \n\t"
+        "punpcklbw %%xmm4, %%xmm2         \n\t"
+        "punpcklbw %%xmm4, %%xmm3         \n\t"
         "movdqa %%xmm0,    64(%1)         \n\t"
         "movdqa %%xmm1,    80(%1)         \n\t"
         "movdqa %%xmm2,    96(%1)         \n\t"
@@ -97,7 +99,7 @@ static inline void diff_pixels_mmx(DCTELEM *block, const uint8_t *s1, const uint
     __asm__ volatile(
         "pxor %%mm7, %%mm7              \n\t"
         "mov $-128, %%"REG_a"           \n\t"
-        ASMALIGN(4)
+        ".p2align 4                     \n\t"
         "1:                             \n\t"
         "movq (%0), %%mm0               \n\t"
         "movq (%1), %%mm2               \n\t"
@@ -323,8 +325,6 @@ static int sse16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int
     return tmp;
 }
 
-int ff_sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h);
-
 static int hf_noise8_mmx(uint8_t * pix1, int line_size, int h) {
     int tmp;
   __asm__ volatile (
@@ -925,17 +925,6 @@ static void sub_hfyu_median_prediction_mmx2(uint8_t *dst, const uint8_t *src1, c
     "paddusw "#t", "#a"               \n\t"\
     "movd "#a", "#dst"                \n\t"\
 
-#define hadamard_func(cpu) \
-int ff_hadamard8_diff_##cpu  (void *s, uint8_t *src1, uint8_t *src2, \
-                              int stride, int h); \
-int ff_hadamard8_diff16_##cpu(void *s, uint8_t *src1, uint8_t *src2, \
-                              int stride, int h);
-
-hadamard_func(mmx)
-hadamard_func(mmx2)
-hadamard_func(sse2)
-hadamard_func(ssse3)
-
 #define DCT_SAD4(m,mm,o)\
     "mov"#m" "#o"+ 0(%1), "#mm"2      \n\t"\
     "mov"#m" "#o"+16(%1), "#mm"3      \n\t"\
@@ -1094,38 +1083,52 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
 #undef PHADDD
 #endif //HAVE_SSSE3
 
+#endif /* HAVE_INLINE_ASM */
+
+int ff_sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h);
 
-void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
+#define hadamard_func(cpu) \
+int ff_hadamard8_diff_##cpu  (void *s, uint8_t *src1, uint8_t *src2, \
+                              int stride, int h); \
+int ff_hadamard8_diff16_##cpu(void *s, uint8_t *src1, uint8_t *src2, \
+                              int stride, int h);
+
+hadamard_func(mmx)
+hadamard_func(mmx2)
+hadamard_func(sse2)
+hadamard_func(ssse3)
+
+void ff_dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
 {
     int mm_flags = av_get_cpu_flags();
 
+#if HAVE_INLINE_ASM
+    int bit_depth = avctx->bits_per_raw_sample;
+
     if (mm_flags & AV_CPU_FLAG_MMX) {
         const int dct_algo = avctx->dct_algo;
-        if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){
+        if (avctx->bits_per_raw_sample <= 8 &&
+            (dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) {
             if(mm_flags & AV_CPU_FLAG_SSE2){
                 c->fdct = ff_fdct_sse2;
-            }else if(mm_flags & AV_CPU_FLAG_MMX2){
+            } else if (mm_flags & AV_CPU_FLAG_MMXEXT) {
                 c->fdct = ff_fdct_mmx2;
             }else{
                 c->fdct = ff_fdct_mmx;
             }
         }
 
-        c->get_pixels = get_pixels_mmx;
+        if (bit_depth <= 8)
+            c->get_pixels = get_pixels_mmx;
         c->diff_pixels = diff_pixels_mmx;
         c->pix_sum = pix_sum16_mmx;
 
         c->diff_bytes= diff_bytes_mmx;
         c->sum_abs_dctelem= sum_abs_dctelem_mmx;
 
-#if HAVE_YASM
-        c->hadamard8_diff[0]= ff_hadamard8_diff16_mmx;
-        c->hadamard8_diff[1]= ff_hadamard8_diff_mmx;
-#endif
-
         c->pix_norm1 = pix_norm1_mmx;
-        c->sse[0] = (HAVE_YASM && mm_flags & AV_CPU_FLAG_SSE2) ? ff_sse16_sse2 : sse16_mmx;
-          c->sse[1] = sse8_mmx;
+        c->sse[0] = sse16_mmx;
+        c->sse[1] = sse8_mmx;
         c->vsad[4]= vsad_intra16_mmx;
 
         c->nsse[0] = nsse16_mmx;
@@ -1141,13 +1144,8 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
 
         c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
 
-
-        if (mm_flags & AV_CPU_FLAG_MMX2) {
+        if (mm_flags & AV_CPU_FLAG_MMXEXT) {
             c->sum_abs_dctelem= sum_abs_dctelem_mmx2;
-#if HAVE_YASM
-            c->hadamard8_diff[0]= ff_hadamard8_diff16_mmx2;
-            c->hadamard8_diff[1]= ff_hadamard8_diff_mmx2;
-#endif
             c->vsad[4]= vsad_intra16_mmx2;
 
             if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
@@ -1158,16 +1156,9 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
         }
 
         if(mm_flags & AV_CPU_FLAG_SSE2){
-            c->get_pixels = get_pixels_sse2;
+            if (bit_depth <= 8)
+                c->get_pixels = get_pixels_sse2;
             c->sum_abs_dctelem= sum_abs_dctelem_sse2;
-#if HAVE_YASM && HAVE_ALIGNED_STACK
-            c->hadamard8_diff[0]= ff_hadamard8_diff16_sse2;
-            c->hadamard8_diff[1]= ff_hadamard8_diff_sse2;
-#endif
-        }
-
-        if (CONFIG_LPC && mm_flags & (AV_CPU_FLAG_SSE2|AV_CPU_FLAG_SSE2SLOW)) {
-            c->lpc_compute_autocorr = ff_lpc_compute_autocorr_sse2;
         }
 
 #if HAVE_SSSE3
@@ -1177,10 +1168,6 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
             }
             c->add_8x8basis= add_8x8basis_ssse3;
             c->sum_abs_dctelem= sum_abs_dctelem_ssse3;
-#if HAVE_YASM && HAVE_ALIGNED_STACK
-            c->hadamard8_diff[0]= ff_hadamard8_diff16_ssse3;
-            c->hadamard8_diff[1]= ff_hadamard8_diff_ssse3;
-#endif
         }
 #endif
 
@@ -1191,6 +1178,35 @@ void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx)
             c->add_8x8basis= add_8x8basis_3dnow;
         }
     }
+#endif /* HAVE_INLINE_ASM */
+
+#if HAVE_YASM
+    if (mm_flags & AV_CPU_FLAG_MMX) {
+        c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx;
+        c->hadamard8_diff[1] = ff_hadamard8_diff_mmx;
+
+        if (mm_flags & AV_CPU_FLAG_MMXEXT) {
+            c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx2;
+            c->hadamard8_diff[1] = ff_hadamard8_diff_mmx2;
+        }
+
+        if (mm_flags & AV_CPU_FLAG_SSE2){
+            c->sse[0] = ff_sse16_sse2;
+
+#if HAVE_ALIGNED_STACK
+            c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2;
+            c->hadamard8_diff[1] = ff_hadamard8_diff_sse2;
+#endif
+        }
+
+#if HAVE_SSSE3 && HAVE_ALIGNED_STACK
+        if (mm_flags & AV_CPU_FLAG_SSSE3) {
+            c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3;
+            c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3;
+        }
+#endif
+    }
+#endif /* HAVE_YASM */
 
-    dsputil_init_pix_mmx(c, avctx);
+    ff_dsputil_init_pix_mmx(c, avctx);
 }