Libav
dsputil_x86.h
Go to the documentation of this file.
1 /*
2  * MMX optimized DSP utils
3  * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org>
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVCODEC_X86_DSPUTIL_X86_H
23 #define AVCODEC_X86_DSPUTIL_X86_H
24 
25 #include <stddef.h>
26 #include <stdint.h>
27 
28 #include "libavcodec/dsputil.h"
29 #include "libavutil/x86/asm.h"
30 #include "constants.h"
31 
32 #define MOVQ_WONE(regd) \
33  __asm__ volatile ( \
34  "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
35  "psrlw $15, %%" #regd ::)
36 
37 #define JUMPALIGN() __asm__ volatile (".p2align 3"::)
38 #define MOVQ_ZERO(regd) __asm__ volatile ("pxor %%"#regd", %%"#regd ::)
39 
40 #define MOVQ_BFE(regd) \
41  __asm__ volatile ( \
42  "pcmpeqd %%"#regd", %%"#regd" \n\t" \
43  "paddb %%"#regd", %%"#regd" \n\t" ::)
44 
45 #ifndef PIC
46 #define MOVQ_WTWO(regd) __asm__ volatile ("movq %0, %%"#regd" \n\t" :: "m"(ff_wtwo))
47 #else
48 // for shared library it's better to use this way for accessing constants
49 // pcmpeqd -> -1
50 #define MOVQ_WTWO(regd) \
51  __asm__ volatile ( \
52  "pcmpeqd %%"#regd", %%"#regd" \n\t" \
53  "psrlw $15, %%"#regd" \n\t" \
54  "psllw $1, %%"#regd" \n\t"::)
55 
56 #endif
57 
58 // using regr as temporary and for the output result
59 // first argument is unmodifed and second is trashed
60 // regfe is supposed to contain 0xfefefefefefefefe
61 #define PAVGB_MMX_NO_RND(rega, regb, regr, regfe) \
62  "movq "#rega", "#regr" \n\t" \
63  "pand "#regb", "#regr" \n\t" \
64  "pxor "#rega", "#regb" \n\t" \
65  "pand "#regfe", "#regb" \n\t" \
66  "psrlq $1, "#regb" \n\t" \
67  "paddb "#regb", "#regr" \n\t"
68 
69 #define PAVGB_MMX(rega, regb, regr, regfe) \
70  "movq "#rega", "#regr" \n\t" \
71  "por "#regb", "#regr" \n\t" \
72  "pxor "#rega", "#regb" \n\t" \
73  "pand "#regfe", "#regb" \n\t" \
74  "psrlq $1, "#regb" \n\t" \
75  "psubb "#regb", "#regr" \n\t"
76 
77 // mm6 is supposed to contain 0xfefefefefefefefe
78 #define PAVGBP_MMX_NO_RND(rega, regb, regr, regc, regd, regp) \
79  "movq "#rega", "#regr" \n\t" \
80  "movq "#regc", "#regp" \n\t" \
81  "pand "#regb", "#regr" \n\t" \
82  "pand "#regd", "#regp" \n\t" \
83  "pxor "#rega", "#regb" \n\t" \
84  "pxor "#regc", "#regd" \n\t" \
85  "pand %%mm6, "#regb" \n\t" \
86  "pand %%mm6, "#regd" \n\t" \
87  "psrlq $1, "#regb" \n\t" \
88  "psrlq $1, "#regd" \n\t" \
89  "paddb "#regb", "#regr" \n\t" \
90  "paddb "#regd", "#regp" \n\t"
91 
92 #define PAVGBP_MMX(rega, regb, regr, regc, regd, regp) \
93  "movq "#rega", "#regr" \n\t" \
94  "movq "#regc", "#regp" \n\t" \
95  "por "#regb", "#regr" \n\t" \
96  "por "#regd", "#regp" \n\t" \
97  "pxor "#rega", "#regb" \n\t" \
98  "pxor "#regc", "#regd" \n\t" \
99  "pand %%mm6, "#regb" \n\t" \
100  "pand %%mm6, "#regd" \n\t" \
101  "psrlq $1, "#regd" \n\t" \
102  "psrlq $1, "#regb" \n\t" \
103  "psubb "#regb", "#regr" \n\t" \
104  "psubb "#regd", "#regp" \n\t"
105 
108 
109 void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
110 void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
111 void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
112 
113 void ff_clear_block_mmx(int16_t *block);
114 void ff_clear_block_sse(int16_t *block);
115 void ff_clear_blocks_mmx(int16_t *blocks);
116 void ff_clear_blocks_sse(int16_t *blocks);
117 
118 void ff_add_bytes_mmx(uint8_t *dst, uint8_t *src, int w);
119 
121  const uint8_t *diff, int w,
122  int *left, int *left_top);
123 
124 void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
125  int w, int h, int sides);
126 
127 void ff_gmc_mmx(uint8_t *dst, uint8_t *src,
128  int stride, int h, int ox, int oy,
129  int dxx, int dxy, int dyx, int dyy,
130  int shift, int r, int width, int height);
131 
132 void ff_vector_clipf_sse(float *dst, const float *src,
133  float min, float max, int len);
134 
135 void ff_avg_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
136  ptrdiff_t line_size, int h);
137 void ff_avg_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
138  ptrdiff_t line_size, int h);
139 void ff_put_pixels8_mmx(uint8_t *block, const uint8_t *pixels,
140  ptrdiff_t line_size, int h);
141 void ff_put_pixels16_mmx(uint8_t *block, const uint8_t *pixels,
142  ptrdiff_t line_size, int h);
143 void ff_avg_pixels8_mmxext(uint8_t *block, const uint8_t *pixels,
144  ptrdiff_t line_size, int h);
145 void ff_put_pixels8_mmxext(uint8_t *block, const uint8_t *pixels,
146  ptrdiff_t line_size, int h);
147 void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
148  ptrdiff_t line_size, int h);
149 void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
150  ptrdiff_t line_size, int h);
151 
152 void ff_avg_pixels8_x2_mmx(uint8_t *block, const uint8_t *pixels,
153  ptrdiff_t line_size, int h);
154 
155 void ff_avg_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels,
156  ptrdiff_t line_size, int h);
157 void ff_avg_pixels16_xy2_mmx(uint8_t *block, const uint8_t *pixels,
158  ptrdiff_t line_size, int h);
159 
160 void ff_put_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels,
161  ptrdiff_t line_size, int h);
162 void ff_put_pixels16_xy2_mmx(uint8_t *block, const uint8_t *pixels,
163  ptrdiff_t line_size, int h);
164 
166  const uint8_t *lum_m4, const uint8_t *lum_m3,
167  const uint8_t *lum_m2, const uint8_t *lum_m1,
168  const uint8_t *lum,
169  int size);
170 
171 void ff_deinterlace_line_inplace_mmx(const uint8_t *lum_m4,
172  const uint8_t *lum_m3,
173  const uint8_t *lum_m2,
174  const uint8_t *lum_m1,
175  const uint8_t *lum, int size);
176 
177 #define PIXELS16(STATIC, PFX1, PFX2, TYPE, CPUEXT) \
178 STATIC void PFX1 ## _pixels16 ## TYPE ## CPUEXT(uint8_t *block, \
179  const uint8_t *pixels, \
180  ptrdiff_t line_size, \
181  int h) \
182 { \
183  PFX2 ## PFX1 ## _pixels8 ## TYPE ## CPUEXT(block, pixels, \
184  line_size, h); \
185  PFX2 ## PFX1 ## _pixels8 ## TYPE ## CPUEXT(block + 8, pixels + 8, \
186  line_size, h); \
187 }
188 
189 #endif /* AVCODEC_X86_DSPUTIL_X86_H */
int size
void ff_put_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
int stride
Definition: mace.c:144
void ff_put_pixels16_xy2_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_clear_blocks_mmx(int16_t *blocks)
void ff_clear_blocks_sse(int16_t *blocks)
uint8_t
void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size)
void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size)
void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx)
Definition: motion_est.c:436
void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
#define r
Definition: input.c:51
void ff_clear_block_sse(int16_t *block)
void ff_put_pixels8_mmxext(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_gmc_mmx(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
void ff_put_pixels8_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
#define wrap(func)
Definition: neontest.h:62
void ff_avg_pixels8_x2_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_avg_pixels16_xy2_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_deinterlace_line_mmx(uint8_t *dst, const uint8_t *lum_m4, const uint8_t *lum_m3, const uint8_t *lum_m2, const uint8_t *lum_m1, const uint8_t *lum, int size)
void ff_avg_pixels8_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
static int width
Definition: utils.c:156
main external API structure.
Definition: avcodec.h:1054
void ff_avg_pixels8_mmxext(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_avg_pixels16_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_clear_block_mmx(int16_t *block)
void ff_avg_pixels8_xy2_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
int height
Definition: gxfenc.c:72
void ff_add_hfyu_median_prediction_cmov(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top)
void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_put_pixels16_mmx(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
DSP utils.
int len
void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides)
void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size)
void ff_deinterlace_line_inplace_mmx(const uint8_t *lum_m4, const uint8_t *lum_m3, const uint8_t *lum_m2, const uint8_t *lum_m1, const uint8_t *lum, int size)
void ff_vector_clipf_sse(float *dst, const float *src, float min, float max, int len)
float min
void ff_add_bytes_mmx(uint8_t *dst, uint8_t *src, int w)
DSPContext.
Definition: dsputil.h:124
static int16_t block[64]
Definition: dct-test.c:170