FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
diracdsp_init.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 David Conrad
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavutil/x86/cpu.h"
22 #include "libavcodec/diracdsp.h"
23 #include "fpel.h"
24 
25 DECL_DIRAC_PIXOP(put, mmx);
26 DECL_DIRAC_PIXOP(avg, mmx);
27 DECL_DIRAC_PIXOP(avg, mmxext);
28 
29 void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
30 void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
31 void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
32 void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
33 
34 void ff_add_rect_clamped_mmx(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
35 void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
36 
37 void ff_add_dirac_obmc8_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
38 void ff_add_dirac_obmc16_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
39 void ff_add_dirac_obmc32_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
40 
41 void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
42 void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
43 
44 void ff_put_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
45 void ff_put_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
46 void ff_put_signed_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
47 void ff_put_signed_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
48 
49 #if HAVE_YASM
50 
51 #define HPEL_FILTER(MMSIZE, EXT) \
52  void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *, const uint8_t *, int, int); \
53  void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, const uint8_t *, int); \
54  \
55  static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \
56  const uint8_t *src, int stride, int width, int height) \
57  { \
58  while( height-- ) \
59  { \
60  ff_dirac_hpel_filter_v_ ## EXT(dstv-MMSIZE, src-MMSIZE, stride, width+MMSIZE+5); \
61  ff_dirac_hpel_filter_h_ ## EXT(dsth, src, width); \
62  ff_dirac_hpel_filter_h_ ## EXT(dstc, dstv, width); \
63  \
64  dsth += stride; \
65  dstv += stride; \
66  dstc += stride; \
67  src += stride; \
68  } \
69  }
70 
71 #define PIXFUNC(PFX, IDX, EXT) \
72  /*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = ff_ ## PFX ## _dirac_pixels8_ ## EXT;*/ \
73  c->PFX ## _dirac_pixels_tab[1][IDX] = ff_ ## PFX ## _dirac_pixels16_ ## EXT; \
74  c->PFX ## _dirac_pixels_tab[2][IDX] = ff_ ## PFX ## _dirac_pixels32_ ## EXT
75 
76 #define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\
77 void ff_ ## OPNAME2 ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
78 {\
79  if (h&3)\
80  ff_ ## OPNAME2 ## _dirac_pixels8_c(dst, src, stride, h);\
81  else\
82  OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\
83 }\
84 void ff_ ## OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
85 {\
86  if (h&3)\
87  ff_ ## OPNAME2 ## _dirac_pixels16_c(dst, src, stride, h);\
88  else\
89  OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
90 }\
91 void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
92 {\
93  if (h&3) {\
94  ff_ ## OPNAME2 ## _dirac_pixels32_c(dst, src, stride, h);\
95  } else {\
96  OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\
97  OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
98  }\
99 }
100 
101 DIRAC_PIXOP(put, ff_put, mmx)
102 DIRAC_PIXOP(avg, ff_avg, mmx)
103 DIRAC_PIXOP(avg, ff_avg, mmxext)
104 
105 void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
106 {
107  if (h&3)
108  ff_put_dirac_pixels16_c(dst, src, stride, h);
109  else
110  ff_put_pixels16_sse2(dst, src[0], stride, h);
111 }
112 void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
113 {
114  if (h&3)
115  ff_avg_dirac_pixels16_c(dst, src, stride, h);
116  else
117  ff_avg_pixels16_sse2(dst, src[0], stride, h);
118 }
119 void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
120 {
121  if (h&3) {
122  ff_put_dirac_pixels32_c(dst, src, stride, h);
123  } else {
124  ff_put_pixels16_sse2(dst , src[0] , stride, h);
125  ff_put_pixels16_sse2(dst+16, src[0]+16, stride, h);
126  }
127 }
128 void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
129 {
130  if (h&3) {
131  ff_avg_dirac_pixels32_c(dst, src, stride, h);
132  } else {
133  ff_avg_pixels16_sse2(dst , src[0] , stride, h);
134  ff_avg_pixels16_sse2(dst+16, src[0]+16, stride, h);
135  }
136 }
137 
138 #else // HAVE_YASM
139 
140 #define HPEL_FILTER(MMSIZE, EXT) \
141  void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \
142  const uint8_t *src, int stride, int width, int height);
143 
144 #define PIXFUNC(PFX, IDX, EXT) do {} while (0)
145 
146 #endif // HAVE_YASM
147 
148 #if !ARCH_X86_64
149 HPEL_FILTER(8, mmx)
150 #endif
151 HPEL_FILTER(16, sse2)
152 
154 {
155  int mm_flags = av_get_cpu_flags();
156 
157  if (EXTERNAL_MMX(mm_flags)) {
158  c->add_dirac_obmc[0] = ff_add_dirac_obmc8_mmx;
159 #if !ARCH_X86_64
160  c->add_dirac_obmc[1] = ff_add_dirac_obmc16_mmx;
161  c->add_dirac_obmc[2] = ff_add_dirac_obmc32_mmx;
162  c->dirac_hpel_filter = dirac_hpel_filter_mmx;
163  c->add_rect_clamped = ff_add_rect_clamped_mmx;
164  c->put_signed_rect_clamped[0] = (void *)ff_put_signed_rect_clamped_mmx;
165 #endif
166  PIXFUNC(put, 0, mmx);
167  PIXFUNC(avg, 0, mmx);
168  }
169 
170  if (EXTERNAL_MMXEXT(mm_flags)) {
171  PIXFUNC(avg, 0, mmxext);
172  }
173 
174  if (EXTERNAL_SSE2(mm_flags)) {
175  c->dirac_hpel_filter = dirac_hpel_filter_sse2;
176  c->add_rect_clamped = ff_add_rect_clamped_sse2;
177  c->put_signed_rect_clamped[0] = (void *)ff_put_signed_rect_clamped_sse2;
178 
179  c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2;
180  c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2;
181 
182  c->put_dirac_pixels_tab[1][0] = ff_put_dirac_pixels16_sse2;
183  c->avg_dirac_pixels_tab[1][0] = ff_avg_dirac_pixels16_sse2;
184  c->put_dirac_pixels_tab[2][0] = ff_put_dirac_pixels32_sse2;
185  c->avg_dirac_pixels_tab[2][0] = ff_avg_dirac_pixels32_sse2;
186  }
187 }
#define EXTERNAL_MMX(flags)
Definition: cpu.h:54
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_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int)
DECL_DIRAC_PIXOP(put, mmx)
void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_add_dirac_obmc32_sse2(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_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
void ff_put_signed_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height)
uint8_t
void ff_put_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height)
#define height
void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
#define EXTERNAL_SSE2(flags)
Definition: cpu.h:57
void ff_add_rect_clamped_mmx(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int)
#define PIXFUNC(PFX, IDX, EXT)
void ff_add_dirac_obmc8_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen)
void ff_put_signed_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height)
void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
#define width
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
#define HPEL_FILTER(MMSIZE, EXT)
#define src
Definition: vp9dsp.c:530
void ff_put_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height)
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:76
#define EXTERNAL_MMXEXT(flags)
Definition: cpu.h:55
#define avg(a, b, c, d)
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
void ff_diracdsp_init_x86(DiracDSPContext *c)
static double c[64]
void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
void ff_add_dirac_obmc32_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen)
void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)