Mercurial > libavcodec.hg
annotate vp8dsp.c @ 12290:2a09b276db12 libavcodec
b0rk3d FATE + black helicopters hissing -> rolling back to r24556 and sleeping
| author | skal |
|---|---|
| date | Tue, 27 Jul 2010 23:09:13 +0000 |
| parents | c7f6ddcc5c01 |
| children | 2d15f62f4f8a |
| rev | line source |
|---|---|
| 11921 | 1 /** |
| 2 * VP8 compatible video decoder | |
| 3 * | |
| 4 * Copyright (C) 2010 David Conrad | |
| 5 * Copyright (C) 2010 Ronald S. Bultje | |
| 6 * | |
| 7 * This file is part of FFmpeg. | |
| 8 * | |
| 9 * FFmpeg is free software; you can redistribute it and/or | |
| 10 * modify it under the terms of the GNU Lesser General Public | |
| 11 * License as published by the Free Software Foundation; either | |
| 12 * version 2.1 of the License, or (at your option) any later version. | |
| 13 * | |
| 14 * FFmpeg is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 * Lesser General Public License for more details. | |
| 18 * | |
| 19 * You should have received a copy of the GNU Lesser General Public | |
| 20 * License along with FFmpeg; if not, write to the Free Software | |
| 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 22 */ | |
| 23 | |
| 24 #include "dsputil.h" | |
| 25 #include "vp8dsp.h" | |
| 26 | |
| 27 // TODO: Maybe add dequant | |
| 28 static void vp8_luma_dc_wht_c(DCTELEM block[4][4][16], DCTELEM dc[16]) | |
| 29 { | |
| 30 int i, t0, t1, t2, t3; | |
| 31 | |
| 32 for (i = 0; i < 4; i++) { | |
| 33 t0 = dc[0*4+i] + dc[3*4+i]; | |
| 34 t1 = dc[1*4+i] + dc[2*4+i]; | |
| 35 t2 = dc[1*4+i] - dc[2*4+i]; | |
| 36 t3 = dc[0*4+i] - dc[3*4+i]; | |
| 37 | |
| 38 dc[0*4+i] = t0 + t1; | |
| 39 dc[1*4+i] = t3 + t2; | |
| 40 dc[2*4+i] = t0 - t1; | |
| 41 dc[3*4+i] = t3 - t2; | |
| 42 } | |
| 43 | |
| 44 for (i = 0; i < 4; i++) { | |
| 45 t0 = dc[i*4+0] + dc[i*4+3] + 3; // rounding | |
| 46 t1 = dc[i*4+1] + dc[i*4+2]; | |
| 47 t2 = dc[i*4+1] - dc[i*4+2]; | |
| 48 t3 = dc[i*4+0] - dc[i*4+3] + 3; // rounding | |
| 49 | |
| 50 *block[i][0] = (t0 + t1) >> 3; | |
| 51 *block[i][1] = (t3 + t2) >> 3; | |
| 52 *block[i][2] = (t0 - t1) >> 3; | |
| 53 *block[i][3] = (t3 - t2) >> 3; | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 | |
| 58 #define MUL_20091(a) ((((a)*20091) >> 16) + (a)) | |
| 59 #define MUL_35468(a) (((a)*35468) >> 16) | |
| 60 | |
| 61 static void vp8_idct_add_c(uint8_t *dst, DCTELEM block[16], int stride) | |
| 62 { | |
| 63 int i, t0, t1, t2, t3; | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
64 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; |
| 11921 | 65 DCTELEM tmp[16]; |
| 66 | |
| 67 for (i = 0; i < 4; i++) { | |
| 68 t0 = block[0*4+i] + block[2*4+i]; | |
| 69 t1 = block[0*4+i] - block[2*4+i]; | |
| 70 t2 = MUL_35468(block[1*4+i]) - MUL_20091(block[3*4+i]); | |
| 71 t3 = MUL_20091(block[1*4+i]) + MUL_35468(block[3*4+i]); | |
|
12235
e08d65897115
VP8: clear DCT blocks in iDCT instead of using clear_blocks.
darkshikari
parents:
12194
diff
changeset
|
72 block[0*4+i] = 0; |
|
e08d65897115
VP8: clear DCT blocks in iDCT instead of using clear_blocks.
darkshikari
parents:
12194
diff
changeset
|
73 block[1*4+i] = 0; |
|
e08d65897115
VP8: clear DCT blocks in iDCT instead of using clear_blocks.
darkshikari
parents:
12194
diff
changeset
|
74 block[2*4+i] = 0; |
|
e08d65897115
VP8: clear DCT blocks in iDCT instead of using clear_blocks.
darkshikari
parents:
12194
diff
changeset
|
75 block[3*4+i] = 0; |
| 11921 | 76 |
| 77 tmp[i*4+0] = t0 + t3; | |
| 78 tmp[i*4+1] = t1 + t2; | |
| 79 tmp[i*4+2] = t1 - t2; | |
| 80 tmp[i*4+3] = t0 - t3; | |
| 81 } | |
| 82 | |
| 83 for (i = 0; i < 4; i++) { | |
| 84 t0 = tmp[0*4+i] + tmp[2*4+i]; | |
| 85 t1 = tmp[0*4+i] - tmp[2*4+i]; | |
| 86 t2 = MUL_35468(tmp[1*4+i]) - MUL_20091(tmp[3*4+i]); | |
| 87 t3 = MUL_20091(tmp[1*4+i]) + MUL_35468(tmp[3*4+i]); | |
| 88 | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
89 dst[0] = cm[dst[0] + ((t0 + t3 + 4) >> 3)]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
90 dst[1] = cm[dst[1] + ((t1 + t2 + 4) >> 3)]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
91 dst[2] = cm[dst[2] + ((t1 - t2 + 4) >> 3)]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
92 dst[3] = cm[dst[3] + ((t0 - t3 + 4) >> 3)]; |
| 11921 | 93 dst += stride; |
| 94 } | |
| 95 } | |
| 96 | |
| 97 static void vp8_idct_dc_add_c(uint8_t *dst, DCTELEM block[16], int stride) | |
| 98 { | |
| 99 int i, dc = (block[0] + 4) >> 3; | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
100 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + dc; |
|
12235
e08d65897115
VP8: clear DCT blocks in iDCT instead of using clear_blocks.
darkshikari
parents:
12194
diff
changeset
|
101 block[0] = 0; |
| 11921 | 102 |
| 103 for (i = 0; i < 4; i++) { | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
104 dst[0] = cm[dst[0]]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
105 dst[1] = cm[dst[1]]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
106 dst[2] = cm[dst[2]]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
107 dst[3] = cm[dst[3]]; |
| 11921 | 108 dst += stride; |
| 109 } | |
| 110 } | |
| 111 | |
|
12241
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
112 static void vp8_idct_dc_add4uv_c(uint8_t *dst, DCTELEM block[4][16], int stride) |
| 12238 | 113 { |
|
12241
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
114 vp8_idct_dc_add_c(dst+stride*0+0, block[0], stride); |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
115 vp8_idct_dc_add_c(dst+stride*0+4, block[1], stride); |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
116 vp8_idct_dc_add_c(dst+stride*4+0, block[2], stride); |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
117 vp8_idct_dc_add_c(dst+stride*4+4, block[3], stride); |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
118 } |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
119 |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
120 static void vp8_idct_dc_add4y_c(uint8_t *dst, DCTELEM block[4][16], int stride) |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
121 { |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
122 vp8_idct_dc_add_c(dst+ 0, block[0], stride); |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
123 vp8_idct_dc_add_c(dst+ 4, block[1], stride); |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
124 vp8_idct_dc_add_c(dst+ 8, block[2], stride); |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
125 vp8_idct_dc_add_c(dst+12, block[3], stride); |
| 12238 | 126 } |
| 11921 | 127 |
| 128 // because I like only having two parameters to pass functions... | |
| 129 #define LOAD_PIXELS\ | |
| 130 int av_unused p3 = p[-4*stride];\ | |
| 131 int av_unused p2 = p[-3*stride];\ | |
| 132 int av_unused p1 = p[-2*stride];\ | |
| 133 int av_unused p0 = p[-1*stride];\ | |
| 134 int av_unused q0 = p[ 0*stride];\ | |
| 135 int av_unused q1 = p[ 1*stride];\ | |
| 136 int av_unused q2 = p[ 2*stride];\ | |
| 137 int av_unused q3 = p[ 3*stride]; | |
| 138 | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
139 #define clip_int8(n) (cm[n+0x80]-0x80) |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
140 |
| 11921 | 141 static av_always_inline void filter_common(uint8_t *p, int stride, int is4tap) |
| 142 { | |
| 143 LOAD_PIXELS | |
| 144 int a, f1, f2; | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
145 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; |
| 11921 | 146 |
| 147 a = 3*(q0 - p0); | |
| 148 | |
| 149 if (is4tap) | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
150 a += clip_int8(p1 - q1); |
| 11921 | 151 |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
152 a = clip_int8(a); |
| 11921 | 153 |
| 154 // We deviate from the spec here with c(a+3) >> 3 | |
| 155 // since that's what libvpx does. | |
| 156 f1 = FFMIN(a+4, 127) >> 3; | |
| 157 f2 = FFMIN(a+3, 127) >> 3; | |
| 158 | |
| 159 // Despite what the spec says, we do need to clamp here to | |
| 160 // be bitexact with libvpx. | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
161 p[-1*stride] = cm[p0 + f2]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
162 p[ 0*stride] = cm[q0 - f1]; |
| 11921 | 163 |
| 164 // only used for _inner on blocks without high edge variance | |
| 165 if (!is4tap) { | |
| 166 a = (f1+1)>>1; | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
167 p[-2*stride] = cm[p1 + a]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
168 p[ 1*stride] = cm[q1 - a]; |
| 11921 | 169 } |
| 170 } | |
| 171 | |
| 172 static av_always_inline int simple_limit(uint8_t *p, int stride, int flim) | |
| 173 { | |
| 174 LOAD_PIXELS | |
| 175 return 2*FFABS(p0-q0) + (FFABS(p1-q1) >> 1) <= flim; | |
| 176 } | |
| 177 | |
| 178 /** | |
| 179 * E - limit at the macroblock edge | |
| 180 * I - limit for interior difference | |
| 181 */ | |
| 182 static av_always_inline int normal_limit(uint8_t *p, int stride, int E, int I) | |
| 183 { | |
| 184 LOAD_PIXELS | |
|
12081
812e23197d64
VP8: Move calculation of outer filter limit out of dsp functions for normal
conrad
parents:
12011
diff
changeset
|
185 return simple_limit(p, stride, E) |
| 11921 | 186 && FFABS(p3-p2) <= I && FFABS(p2-p1) <= I && FFABS(p1-p0) <= I |
| 187 && FFABS(q3-q2) <= I && FFABS(q2-q1) <= I && FFABS(q1-q0) <= I; | |
| 188 } | |
| 189 | |
| 190 // high edge variance | |
| 191 static av_always_inline int hev(uint8_t *p, int stride, int thresh) | |
| 192 { | |
| 193 LOAD_PIXELS | |
| 194 return FFABS(p1-p0) > thresh || FFABS(q1-q0) > thresh; | |
| 195 } | |
| 196 | |
| 197 static av_always_inline void filter_mbedge(uint8_t *p, int stride) | |
| 198 { | |
| 199 int a0, a1, a2, w; | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
200 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; |
| 11921 | 201 |
| 202 LOAD_PIXELS | |
| 203 | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
204 w = clip_int8(p1-q1); |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
205 w = clip_int8(w + 3*(q0-p0)); |
| 11921 | 206 |
| 207 a0 = (27*w + 63) >> 7; | |
| 208 a1 = (18*w + 63) >> 7; | |
| 209 a2 = ( 9*w + 63) >> 7; | |
| 210 | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
211 p[-3*stride] = cm[p2 + a2]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
212 p[-2*stride] = cm[p1 + a1]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
213 p[-1*stride] = cm[p0 + a0]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
214 p[ 0*stride] = cm[q0 - a0]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
215 p[ 1*stride] = cm[q1 - a1]; |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
216 p[ 2*stride] = cm[q2 - a2]; |
| 11921 | 217 } |
| 218 | |
|
12194
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
219 #define LOOP_FILTER(dir, size, stridea, strideb, maybe_inline) \ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
220 static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _c(uint8_t *dst, int stride,\ |
| 11921 | 221 int flim_E, int flim_I, int hev_thresh)\ |
| 222 {\ | |
| 223 int i;\ | |
| 224 \ | |
| 225 for (i = 0; i < size; i++)\ | |
| 226 if (normal_limit(dst+i*stridea, strideb, flim_E, flim_I)) {\ | |
| 227 if (hev(dst+i*stridea, strideb, hev_thresh))\ | |
| 228 filter_common(dst+i*stridea, strideb, 1);\ | |
| 229 else\ | |
| 230 filter_mbedge(dst+i*stridea, strideb);\ | |
| 231 }\ | |
| 232 }\ | |
| 233 \ | |
|
12194
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
234 static maybe_inline void vp8_ ## dir ## _loop_filter ## size ## _inner_c(uint8_t *dst, int stride,\ |
| 11921 | 235 int flim_E, int flim_I, int hev_thresh)\ |
| 236 {\ | |
| 12008 | 237 int i;\ |
| 11921 | 238 \ |
| 239 for (i = 0; i < size; i++)\ | |
| 240 if (normal_limit(dst+i*stridea, strideb, flim_E, flim_I)) {\ | |
| 12008 | 241 int hv = hev(dst+i*stridea, strideb, hev_thresh);\ |
| 242 if (hv) \ | |
| 243 filter_common(dst+i*stridea, strideb, 1);\ | |
| 244 else \ | |
| 245 filter_common(dst+i*stridea, strideb, 0);\ | |
| 11921 | 246 }\ |
| 247 } | |
| 248 | |
|
12194
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
249 LOOP_FILTER(v, 16, 1, stride,) |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
250 LOOP_FILTER(h, 16, stride, 1,) |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
251 |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
252 #define UV_LOOP_FILTER(dir, stridea, strideb) \ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
253 LOOP_FILTER(dir, 8, stridea, strideb, av_always_inline) \ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
254 static void vp8_ ## dir ## _loop_filter8uv_c(uint8_t *dstU, uint8_t *dstV, int stride,\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
255 int fE, int fI, int hev_thresh)\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
256 {\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
257 vp8_ ## dir ## _loop_filter8_c(dstU, stride, fE, fI, hev_thresh);\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
258 vp8_ ## dir ## _loop_filter8_c(dstV, stride, fE, fI, hev_thresh);\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
259 }\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
260 static void vp8_ ## dir ## _loop_filter8uv_inner_c(uint8_t *dstU, uint8_t *dstV, int stride,\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
261 int fE, int fI, int hev_thresh)\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
262 {\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
263 vp8_ ## dir ## _loop_filter8_inner_c(dstU, stride, fE, fI, hev_thresh);\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
264 vp8_ ## dir ## _loop_filter8_inner_c(dstV, stride, fE, fI, hev_thresh);\ |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
265 } |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
266 |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
267 UV_LOOP_FILTER(v, 1, stride) |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
268 UV_LOOP_FILTER(h, stride, 1) |
| 11921 | 269 |
| 270 static void vp8_v_loop_filter_simple_c(uint8_t *dst, int stride, int flim) | |
| 271 { | |
| 272 int i; | |
| 273 | |
| 274 for (i = 0; i < 16; i++) | |
| 275 if (simple_limit(dst+i, stride, flim)) | |
| 276 filter_common(dst+i, stride, 1); | |
| 277 } | |
| 278 | |
| 279 static void vp8_h_loop_filter_simple_c(uint8_t *dst, int stride, int flim) | |
| 280 { | |
| 281 int i; | |
| 282 | |
| 283 for (i = 0; i < 16; i++) | |
| 284 if (simple_limit(dst+i*stride, 1, flim)) | |
| 285 filter_common(dst+i*stride, 1, 1); | |
| 286 } | |
| 287 | |
| 288 static const uint8_t subpel_filters[7][6] = { | |
| 289 { 0, 6, 123, 12, 1, 0 }, | |
| 290 { 2, 11, 108, 36, 8, 1 }, | |
| 291 { 0, 9, 93, 50, 6, 0 }, | |
| 292 { 3, 16, 77, 77, 16, 3 }, | |
| 293 { 0, 6, 50, 93, 9, 0 }, | |
| 294 { 1, 8, 36, 108, 11, 2 }, | |
| 295 { 0, 1, 12, 123, 6, 0 }, | |
| 296 }; | |
| 297 | |
| 11950 | 298 #define PUT_PIXELS(WIDTH) \ |
| 299 static void put_vp8_pixels ## WIDTH ##_c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int x, int y) { \ | |
| 11956 | 300 int i; \ |
| 301 for (i = 0; i < h; i++, dst+= dststride, src+= srcstride) { \ | |
| 11950 | 302 memcpy(dst, src, WIDTH); \ |
| 303 } \ | |
| 304 } | |
| 305 | |
| 306 PUT_PIXELS(16) | |
| 307 PUT_PIXELS(8) | |
| 308 PUT_PIXELS(4) | |
| 11921 | 309 |
| 310 #define FILTER_6TAP(src, F, stride) \ | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
311 cm[(F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + F[0]*src[x-2*stride] + \ |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
312 F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + F[5]*src[x+3*stride] + 64) >> 7] |
| 11921 | 313 |
| 314 #define FILTER_4TAP(src, F, stride) \ | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
315 cm[(F[2]*src[x+0*stride] - F[1]*src[x-1*stride] + \ |
|
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
316 F[3]*src[x+1*stride] - F[4]*src[x+2*stride] + 64) >> 7] |
| 11921 | 317 |
| 318 #define VP8_EPEL_H(SIZE, FILTER, FILTERNAME) \ | |
| 11950 | 319 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ |
| 11921 | 320 { \ |
| 321 const uint8_t *filter = subpel_filters[mx-1]; \ | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
322 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ |
| 11921 | 323 int x, y; \ |
| 324 \ | |
| 325 for (y = 0; y < h; y++) { \ | |
| 326 for (x = 0; x < SIZE; x++) \ | |
| 327 dst[x] = FILTER(src, filter, 1); \ | |
| 11950 | 328 dst += dststride; \ |
| 329 src += srcstride; \ | |
| 11921 | 330 } \ |
| 331 } | |
| 332 #define VP8_EPEL_V(SIZE, FILTER, FILTERNAME) \ | |
| 11950 | 333 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ |
| 11921 | 334 { \ |
| 335 const uint8_t *filter = subpel_filters[my-1]; \ | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
336 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ |
| 11921 | 337 int x, y; \ |
| 338 \ | |
| 339 for (y = 0; y < h; y++) { \ | |
| 340 for (x = 0; x < SIZE; x++) \ | |
| 11950 | 341 dst[x] = FILTER(src, filter, srcstride); \ |
| 342 dst += dststride; \ | |
| 343 src += srcstride; \ | |
| 11921 | 344 } \ |
| 345 } | |
| 346 #define VP8_EPEL_HV(SIZE, FILTERX, FILTERY, FILTERNAME) \ | |
| 11950 | 347 static void put_vp8_epel ## SIZE ## _ ## FILTERNAME ## _c(uint8_t *dst, int dststride, uint8_t *src, int srcstride, int h, int mx, int my) \ |
| 11921 | 348 { \ |
| 349 const uint8_t *filter = subpel_filters[mx-1]; \ | |
|
12007
ec7be1d7d5b4
Use crop table in C implementations of VP8 DSP functions.
darkshikari
parents:
11985
diff
changeset
|
350 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \ |
| 11921 | 351 int x, y; \ |
| 352 uint8_t tmp_array[(2*SIZE+5)*SIZE]; \ | |
| 353 uint8_t *tmp = tmp_array; \ | |
| 11950 | 354 src -= 2*srcstride; \ |
| 11921 | 355 \ |
| 356 for (y = 0; y < h+5; y++) { \ | |
| 357 for (x = 0; x < SIZE; x++) \ | |
| 358 tmp[x] = FILTERX(src, filter, 1); \ | |
| 359 tmp += SIZE; \ | |
| 11950 | 360 src += srcstride; \ |
| 11921 | 361 } \ |
| 362 \ | |
| 363 tmp = tmp_array + 2*SIZE; \ | |
| 364 filter = subpel_filters[my-1]; \ | |
| 365 \ | |
| 366 for (y = 0; y < h; y++) { \ | |
| 367 for (x = 0; x < SIZE; x++) \ | |
| 368 dst[x] = FILTERY(tmp, filter, SIZE); \ | |
| 11950 | 369 dst += dststride; \ |
| 11921 | 370 tmp += SIZE; \ |
| 371 } \ | |
| 372 } | |
| 373 | |
| 374 VP8_EPEL_H(16, FILTER_4TAP, h4) | |
| 375 VP8_EPEL_H(8, FILTER_4TAP, h4) | |
| 376 VP8_EPEL_H(4, FILTER_4TAP, h4) | |
| 377 VP8_EPEL_H(16, FILTER_6TAP, h6) | |
| 378 VP8_EPEL_H(8, FILTER_6TAP, h6) | |
| 379 VP8_EPEL_H(4, FILTER_6TAP, h6) | |
| 380 VP8_EPEL_V(16, FILTER_4TAP, v4) | |
| 381 VP8_EPEL_V(8, FILTER_4TAP, v4) | |
| 382 VP8_EPEL_V(4, FILTER_4TAP, v4) | |
| 383 VP8_EPEL_V(16, FILTER_6TAP, v6) | |
| 384 VP8_EPEL_V(8, FILTER_6TAP, v6) | |
| 385 VP8_EPEL_V(4, FILTER_6TAP, v6) | |
| 386 VP8_EPEL_HV(16, FILTER_4TAP, FILTER_4TAP, h4v4) | |
| 387 VP8_EPEL_HV(8, FILTER_4TAP, FILTER_4TAP, h4v4) | |
| 388 VP8_EPEL_HV(4, FILTER_4TAP, FILTER_4TAP, h4v4) | |
| 389 VP8_EPEL_HV(16, FILTER_4TAP, FILTER_6TAP, h4v6) | |
| 390 VP8_EPEL_HV(8, FILTER_4TAP, FILTER_6TAP, h4v6) | |
| 391 VP8_EPEL_HV(4, FILTER_4TAP, FILTER_6TAP, h4v6) | |
| 392 VP8_EPEL_HV(16, FILTER_6TAP, FILTER_4TAP, h6v4) | |
| 393 VP8_EPEL_HV(8, FILTER_6TAP, FILTER_4TAP, h6v4) | |
| 394 VP8_EPEL_HV(4, FILTER_6TAP, FILTER_4TAP, h6v4) | |
| 395 VP8_EPEL_HV(16, FILTER_6TAP, FILTER_6TAP, h6v6) | |
| 396 VP8_EPEL_HV(8, FILTER_6TAP, FILTER_6TAP, h6v6) | |
| 397 VP8_EPEL_HV(4, FILTER_6TAP, FILTER_6TAP, h6v6) | |
| 398 | |
| 11974 | 399 #define VP8_BILINEAR(SIZE) \ |
| 400 static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ | |
| 401 { \ | |
| 402 int a = 8-mx, b = mx; \ | |
| 403 int x, y; \ | |
| 404 \ | |
| 405 for (y = 0; y < h; y++) { \ | |
| 406 for (x = 0; x < SIZE; x++) \ | |
| 407 dst[x] = (a*src[x] + b*src[x+1] + 4) >> 3; \ | |
| 408 dst += stride; \ | |
| 409 src += stride; \ | |
| 410 } \ | |
| 411 } \ | |
| 412 static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ | |
| 413 { \ | |
| 414 int c = 8-my, d = my; \ | |
| 415 int x, y; \ | |
| 416 \ | |
| 417 for (y = 0; y < h; y++) { \ | |
| 418 for (x = 0; x < SIZE; x++) \ | |
| 419 dst[x] = (c*src[x] + d*src[x+stride] + 4) >> 3; \ | |
| 420 dst += stride; \ | |
| 421 src += stride; \ | |
| 422 } \ | |
| 423 } \ | |
| 424 \ | |
| 425 static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \ | |
| 426 { \ | |
| 427 int a = 8-mx, b = mx; \ | |
| 428 int c = 8-my, d = my; \ | |
| 429 int x, y; \ | |
| 430 uint8_t tmp_array[(2*SIZE+1)*SIZE]; \ | |
| 431 uint8_t *tmp = tmp_array; \ | |
| 432 \ | |
| 433 for (y = 0; y < h+1; y++) { \ | |
| 434 for (x = 0; x < SIZE; x++) \ | |
| 435 tmp[x] = (a*src[x] + b*src[x+1] + 4) >> 3; \ | |
| 436 tmp += SIZE; \ | |
| 437 src += stride; \ | |
| 438 } \ | |
| 439 \ | |
| 440 tmp = tmp_array; \ | |
| 441 \ | |
| 442 for (y = 0; y < h; y++) { \ | |
| 443 for (x = 0; x < SIZE; x++) \ | |
| 444 dst[x] = (c*tmp[x] + d*tmp[x+SIZE] + 4) >> 3; \ | |
| 445 dst += stride; \ | |
| 446 tmp += SIZE; \ | |
| 447 } \ | |
| 448 } | |
| 449 | |
| 450 VP8_BILINEAR(16) | |
| 451 VP8_BILINEAR(8) | |
| 452 VP8_BILINEAR(4) | |
| 453 | |
| 11921 | 454 #define VP8_MC_FUNC(IDX, SIZE) \ |
| 11950 | 455 dsp->put_vp8_epel_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \ |
| 11921 | 456 dsp->put_vp8_epel_pixels_tab[IDX][0][1] = put_vp8_epel ## SIZE ## _h4_c; \ |
| 457 dsp->put_vp8_epel_pixels_tab[IDX][0][2] = put_vp8_epel ## SIZE ## _h6_c; \ | |
| 458 dsp->put_vp8_epel_pixels_tab[IDX][1][0] = put_vp8_epel ## SIZE ## _v4_c; \ | |
| 459 dsp->put_vp8_epel_pixels_tab[IDX][1][1] = put_vp8_epel ## SIZE ## _h4v4_c; \ | |
| 460 dsp->put_vp8_epel_pixels_tab[IDX][1][2] = put_vp8_epel ## SIZE ## _h6v4_c; \ | |
| 461 dsp->put_vp8_epel_pixels_tab[IDX][2][0] = put_vp8_epel ## SIZE ## _v6_c; \ | |
| 462 dsp->put_vp8_epel_pixels_tab[IDX][2][1] = put_vp8_epel ## SIZE ## _h4v6_c; \ | |
| 463 dsp->put_vp8_epel_pixels_tab[IDX][2][2] = put_vp8_epel ## SIZE ## _h6v6_c | |
| 464 | |
| 11974 | 465 #define VP8_BILINEAR_MC_FUNC(IDX, SIZE) \ |
| 466 dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \ | |
| 467 dsp->put_vp8_bilinear_pixels_tab[IDX][0][1] = put_vp8_bilinear ## SIZE ## _h_c; \ | |
| 468 dsp->put_vp8_bilinear_pixels_tab[IDX][0][2] = put_vp8_bilinear ## SIZE ## _h_c; \ | |
| 469 dsp->put_vp8_bilinear_pixels_tab[IDX][1][0] = put_vp8_bilinear ## SIZE ## _v_c; \ | |
| 470 dsp->put_vp8_bilinear_pixels_tab[IDX][1][1] = put_vp8_bilinear ## SIZE ## _hv_c; \ | |
| 471 dsp->put_vp8_bilinear_pixels_tab[IDX][1][2] = put_vp8_bilinear ## SIZE ## _hv_c; \ | |
| 472 dsp->put_vp8_bilinear_pixels_tab[IDX][2][0] = put_vp8_bilinear ## SIZE ## _v_c; \ | |
| 473 dsp->put_vp8_bilinear_pixels_tab[IDX][2][1] = put_vp8_bilinear ## SIZE ## _hv_c; \ | |
| 474 dsp->put_vp8_bilinear_pixels_tab[IDX][2][2] = put_vp8_bilinear ## SIZE ## _hv_c | |
| 475 | |
| 11921 | 476 av_cold void ff_vp8dsp_init(VP8DSPContext *dsp) |
| 477 { | |
|
12241
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
478 dsp->vp8_luma_dc_wht = vp8_luma_dc_wht_c; |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
479 dsp->vp8_idct_add = vp8_idct_add_c; |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
480 dsp->vp8_idct_dc_add = vp8_idct_dc_add_c; |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
481 dsp->vp8_idct_dc_add4y = vp8_idct_dc_add4y_c; |
|
c7f6ddcc5c01
VP8: optimize DC-only chroma case in the same way as luma.
darkshikari
parents:
12238
diff
changeset
|
482 dsp->vp8_idct_dc_add4uv = vp8_idct_dc_add4uv_c; |
| 11921 | 483 |
|
12194
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
484 dsp->vp8_v_loop_filter16y = vp8_v_loop_filter16_c; |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
485 dsp->vp8_h_loop_filter16y = vp8_h_loop_filter16_c; |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
486 dsp->vp8_v_loop_filter8uv = vp8_v_loop_filter8uv_c; |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
487 dsp->vp8_h_loop_filter8uv = vp8_h_loop_filter8uv_c; |
| 11921 | 488 |
|
12194
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
489 dsp->vp8_v_loop_filter16y_inner = vp8_v_loop_filter16_inner_c; |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
490 dsp->vp8_h_loop_filter16y_inner = vp8_h_loop_filter16_inner_c; |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
491 dsp->vp8_v_loop_filter8uv_inner = vp8_v_loop_filter8uv_inner_c; |
|
80b142c2e9f7
Change function prototypes for width=8 inner and mbedge loopfilter functions
rbultje
parents:
12081
diff
changeset
|
492 dsp->vp8_h_loop_filter8uv_inner = vp8_h_loop_filter8uv_inner_c; |
| 11921 | 493 |
| 494 dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c; | |
| 495 dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c; | |
| 496 | |
| 497 VP8_MC_FUNC(0, 16); | |
| 498 VP8_MC_FUNC(1, 8); | |
| 499 VP8_MC_FUNC(2, 4); | |
| 11974 | 500 |
| 501 VP8_BILINEAR_MC_FUNC(0, 16); | |
| 502 VP8_BILINEAR_MC_FUNC(1, 8); | |
| 503 VP8_BILINEAR_MC_FUNC(2, 4); | |
| 11975 | 504 |
| 11985 | 505 if (HAVE_MMX) |
| 11975 | 506 ff_vp8dsp_init_x86(dsp); |
| 12011 | 507 if (HAVE_ALTIVEC) |
| 508 ff_vp8dsp_init_altivec(dsp); | |
| 11921 | 509 } |
