H264: change weight/biweight functions to take a height argument.
[ffmpeg.git] / libavcodec / x86 / h264dsp_mmx.c
index 06ee7ca..dcd9180 100644 (file)
@@ -298,57 +298,47 @@ LF_IFUNC(v,  luma_intra,      10, mmxext)
 /***********************************/
 /* weighted prediction */
 
-#define H264_WEIGHT(W, H, OPT) \
-void ff_h264_weight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \
-    int stride, int log2_denom, int weight, int offset);
+#define H264_WEIGHT(W, OPT) \
+void ff_h264_weight_ ## W ## _ ## OPT(uint8_t *dst, \
+    int stride, int height, int log2_denom, int weight, int offset);
 
-#define H264_BIWEIGHT(W, H, OPT) \
-void ff_h264_biweight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \
-    uint8_t *src, int stride, int log2_denom, int weightd, \
+#define H264_BIWEIGHT(W, OPT) \
+void ff_h264_biweight_ ## W ## _ ## OPT(uint8_t *dst, \
+    uint8_t *src, int stride, int height, int log2_denom, int weightd, \
     int weights, int offset);
 
-#define H264_BIWEIGHT_MMX(W,H) \
-H264_WEIGHT  (W, H, mmx2) \
-H264_BIWEIGHT(W, H, mmx2)
-
-#define H264_BIWEIGHT_MMX_SSE(W,H) \
-H264_BIWEIGHT_MMX(W, H) \
-H264_WEIGHT      (W, H, sse2) \
-H264_BIWEIGHT    (W, H, sse2) \
-H264_BIWEIGHT    (W, H, ssse3)
-
-H264_BIWEIGHT_MMX_SSE(16, 16)
-H264_BIWEIGHT_MMX_SSE(16,  8)
-H264_BIWEIGHT_MMX_SSE( 8, 16)
-H264_BIWEIGHT_MMX_SSE( 8,  8)
-H264_BIWEIGHT_MMX_SSE( 8,  4)
-H264_BIWEIGHT_MMX    ( 4,  8)
-H264_BIWEIGHT_MMX    ( 4,  4)
-H264_BIWEIGHT_MMX    ( 4,  2)
-
-#define H264_WEIGHT_10(W, H, DEPTH, OPT) \
-void ff_h264_weight_ ## W ## x ## H ## _ ## DEPTH ## _ ## OPT(uint8_t *dst, \
-    int stride, int log2_denom, int weight, int offset);
-
-#define H264_BIWEIGHT_10(W, H, DEPTH, OPT) \
-void ff_h264_biweight_ ## W ## x ## H ## _ ## DEPTH ## _ ## OPT \
-    (uint8_t *dst, uint8_t *src, int stride, int log2_denom, \
+#define H264_BIWEIGHT_MMX(W) \
+H264_WEIGHT  (W, mmx2) \
+H264_BIWEIGHT(W, mmx2)
+
+#define H264_BIWEIGHT_MMX_SSE(W) \
+H264_BIWEIGHT_MMX(W) \
+H264_WEIGHT      (W, sse2) \
+H264_BIWEIGHT    (W, sse2) \
+H264_BIWEIGHT    (W, ssse3)
+
+H264_BIWEIGHT_MMX_SSE(16)
+H264_BIWEIGHT_MMX_SSE( 8)
+H264_BIWEIGHT_MMX    ( 4)
+
+#define H264_WEIGHT_10(W, DEPTH, OPT) \
+void ff_h264_weight_ ## W ## _ ## DEPTH ## _ ## OPT(uint8_t *dst, \
+    int stride, int height, int log2_denom, int weight, int offset);
+
+#define H264_BIWEIGHT_10(W, DEPTH, OPT) \
+void ff_h264_biweight_ ## W ## _ ## DEPTH ## _ ## OPT \
+    (uint8_t *dst, uint8_t *src, int stride, int height, int log2_denom, \
      int weightd, int weights, int offset);
 
-#define H264_BIWEIGHT_10_SSE(W, H, DEPTH) \
-H264_WEIGHT_10  (W, H, DEPTH, sse2) \
-H264_WEIGHT_10  (W, H, DEPTH, sse4) \
-H264_BIWEIGHT_10(W, H, DEPTH, sse2) \
-H264_BIWEIGHT_10(W, H, DEPTH, sse4)
-
-H264_BIWEIGHT_10_SSE(16, 16, 10)
-H264_BIWEIGHT_10_SSE(16,  8, 10)
-H264_BIWEIGHT_10_SSE( 8, 16, 10)
-H264_BIWEIGHT_10_SSE( 8,  8, 10)
-H264_BIWEIGHT_10_SSE( 8,  4, 10)
-H264_BIWEIGHT_10_SSE( 4,  8, 10)
-H264_BIWEIGHT_10_SSE( 4,  4, 10)
-H264_BIWEIGHT_10_SSE( 4,  2, 10)
+#define H264_BIWEIGHT_10_SSE(W, DEPTH) \
+H264_WEIGHT_10  (W, DEPTH, sse2) \
+H264_WEIGHT_10  (W, DEPTH, sse4) \
+H264_BIWEIGHT_10(W, DEPTH, sse2) \
+H264_BIWEIGHT_10(W, DEPTH, sse4)
+
+H264_BIWEIGHT_10_SSE(16, 10)
+H264_BIWEIGHT_10_SSE( 8, 10)
+H264_BIWEIGHT_10_SSE( 4, 10)
 
 void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
 {
@@ -394,23 +384,13 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chrom
             c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_mmxext;
             c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_mmxext;
 #endif
-            c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;
-            c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;
-            c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;
-            c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;
-            c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;
-            c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;
-            c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;
-            c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;
-
-            c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;
-            c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;
-            c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;
-            c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;
-            c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;
-            c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;
-            c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;
-            c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
+            c->weight_h264_pixels_tab[0]= ff_h264_weight_16_mmx2;
+            c->weight_h264_pixels_tab[1]= ff_h264_weight_8_mmx2;
+            c->weight_h264_pixels_tab[2]= ff_h264_weight_4_mmx2;
+
+            c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16_mmx2;
+            c->biweight_h264_pixels_tab[1]= ff_h264_biweight_8_mmx2;
+            c->biweight_h264_pixels_tab[2]= ff_h264_biweight_4_mmx2;
 
             if (mm_flags&AV_CPU_FLAG_SSE2) {
                 c->h264_idct8_add           = ff_h264_idct8_add_8_sse2;
@@ -422,17 +402,11 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chrom
                 c->h264_idct_add16intra     = ff_h264_idct_add16intra_8_sse2;
                 c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_sse2;
 
-                c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_sse2;
-                c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_sse2;
-                c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_sse2;
-                c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_sse2;
-                c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_sse2;
+                c->weight_h264_pixels_tab[0]= ff_h264_weight_16_sse2;
+                c->weight_h264_pixels_tab[1]= ff_h264_weight_8_sse2;
 
-                c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_sse2;
-                c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_sse2;
-                c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_sse2;
-                c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_sse2;
-                c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_sse2;
+                c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16_sse2;
+                c->biweight_h264_pixels_tab[1]= ff_h264_biweight_8_sse2;
 
 #if HAVE_ALIGNED_STACK
                 c->h264_v_loop_filter_luma = ff_deblock_v_luma_8_sse2;
@@ -442,11 +416,8 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chrom
 #endif
             }
             if (mm_flags&AV_CPU_FLAG_SSSE3) {
-                c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3;
-                c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_ssse3;
-                c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_ssse3;
-                c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_ssse3;
-                c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_ssse3;
+                c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16_ssse3;
+                c->biweight_h264_pixels_tab[1]= ff_h264_biweight_8_ssse3;
             }
             if (mm_flags&AV_CPU_FLAG_AVX) {
 #if HAVE_ALIGNED_STACK
@@ -485,23 +456,13 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chrom
                 c->h264_idct8_add4     = ff_h264_idct8_add4_10_sse2;
 #endif
 
-                c->weight_h264_pixels_tab[0] = ff_h264_weight_16x16_10_sse2;
-                c->weight_h264_pixels_tab[1] = ff_h264_weight_16x8_10_sse2;
-                c->weight_h264_pixels_tab[2] = ff_h264_weight_8x16_10_sse2;
-                c->weight_h264_pixels_tab[3] = ff_h264_weight_8x8_10_sse2;
-                c->weight_h264_pixels_tab[4] = ff_h264_weight_8x4_10_sse2;
-                c->weight_h264_pixels_tab[5] = ff_h264_weight_4x8_10_sse2;
-                c->weight_h264_pixels_tab[6] = ff_h264_weight_4x4_10_sse2;
-                c->weight_h264_pixels_tab[7] = ff_h264_weight_4x2_10_sse2;
-
-                c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16x16_10_sse2;
-                c->biweight_h264_pixels_tab[1] = ff_h264_biweight_16x8_10_sse2;
-                c->biweight_h264_pixels_tab[2] = ff_h264_biweight_8x16_10_sse2;
-                c->biweight_h264_pixels_tab[3] = ff_h264_biweight_8x8_10_sse2;
-                c->biweight_h264_pixels_tab[4] = ff_h264_biweight_8x4_10_sse2;
-                c->biweight_h264_pixels_tab[5] = ff_h264_biweight_4x8_10_sse2;
-                c->biweight_h264_pixels_tab[6] = ff_h264_biweight_4x4_10_sse2;
-                c->biweight_h264_pixels_tab[7] = ff_h264_biweight_4x2_10_sse2;
+                c->weight_h264_pixels_tab[0] = ff_h264_weight_16_10_sse2;
+                c->weight_h264_pixels_tab[1] = ff_h264_weight_8_10_sse2;
+                c->weight_h264_pixels_tab[2] = ff_h264_weight_4_10_sse2;
+
+                c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_10_sse2;
+                c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_10_sse2;
+                c->biweight_h264_pixels_tab[2] = ff_h264_biweight_4_10_sse2;
 
                 c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_sse2;
                 c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_sse2;
@@ -513,23 +474,13 @@ void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chrom
 #endif
             }
             if (mm_flags&AV_CPU_FLAG_SSE4) {
-                c->weight_h264_pixels_tab[0] = ff_h264_weight_16x16_10_sse4;
-                c->weight_h264_pixels_tab[1] = ff_h264_weight_16x8_10_sse4;
-                c->weight_h264_pixels_tab[2] = ff_h264_weight_8x16_10_sse4;
-                c->weight_h264_pixels_tab[3] = ff_h264_weight_8x8_10_sse4;
-                c->weight_h264_pixels_tab[4] = ff_h264_weight_8x4_10_sse4;
-                c->weight_h264_pixels_tab[5] = ff_h264_weight_4x8_10_sse4;
-                c->weight_h264_pixels_tab[6] = ff_h264_weight_4x4_10_sse4;
-                c->weight_h264_pixels_tab[7] = ff_h264_weight_4x2_10_sse4;
-
-                c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16x16_10_sse4;
-                c->biweight_h264_pixels_tab[1] = ff_h264_biweight_16x8_10_sse4;
-                c->biweight_h264_pixels_tab[2] = ff_h264_biweight_8x16_10_sse4;
-                c->biweight_h264_pixels_tab[3] = ff_h264_biweight_8x8_10_sse4;
-                c->biweight_h264_pixels_tab[4] = ff_h264_biweight_8x4_10_sse4;
-                c->biweight_h264_pixels_tab[5] = ff_h264_biweight_4x8_10_sse4;
-                c->biweight_h264_pixels_tab[6] = ff_h264_biweight_4x4_10_sse4;
-                c->biweight_h264_pixels_tab[7] = ff_h264_biweight_4x2_10_sse4;
+                c->weight_h264_pixels_tab[0] = ff_h264_weight_16_10_sse4;
+                c->weight_h264_pixels_tab[1] = ff_h264_weight_8_10_sse4;
+                c->weight_h264_pixels_tab[2] = ff_h264_weight_4_10_sse4;
+
+                c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_10_sse4;
+                c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_10_sse4;
+                c->biweight_h264_pixels_tab[2] = ff_h264_biweight_4_10_sse4;
             }
 #if HAVE_AVX
             if (mm_flags&AV_CPU_FLAG_AVX) {