Mercurial > libavcodec.hg
annotate dsputil.c @ 664:00a882f626bd libavcodec
interlaced mpeg4 b frame decoding
| author | michaelni |
|---|---|
| date | Fri, 13 Sep 2002 09:45:32 +0000 |
| parents | 45e8f39fda50 |
| children | c3bdb00a98a9 |
| rev | line source |
|---|---|
| 0 | 1 /* |
| 2 * DSP utils | |
| 429 | 3 * Copyright (c) 2000, 2001 Fabrice Bellard. |
| 0 | 4 * |
| 429 | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Lesser General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2 of the License, or (at your option) any later version. | |
| 0 | 9 * |
| 429 | 10 * This library is distributed in the hope that it will be useful, |
| 0 | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Lesser General Public License for more details. | |
| 0 | 14 * |
| 429 | 15 * You should have received a copy of the GNU Lesser General Public |
| 16 * License along with this library; if not, write to the Free Software | |
| 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 256 | 18 * |
| 385 | 19 * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at> |
| 0 | 20 */ |
| 21 #include "avcodec.h" | |
| 22 #include "dsputil.h" | |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
23 #include "simple_idct.h" |
| 0 | 24 |
|
19
82d4c9be9873
MMX/MMXEXT iDCT support, using external functions currently defined in libmpeg2
arpi_esp
parents:
6
diff
changeset
|
25 void (*ff_idct)(DCTELEM *block); |
| 480 | 26 void (*ff_idct_put)(UINT8 *dest, int line_size, DCTELEM *block); |
| 27 void (*ff_idct_add)(UINT8 *dest, int line_size, DCTELEM *block); | |
| 0 | 28 void (*get_pixels)(DCTELEM *block, const UINT8 *pixels, int line_size); |
| 324 | 29 void (*diff_pixels)(DCTELEM *block, const UINT8 *s1, const UINT8 *s2, int stride); |
| 0 | 30 void (*put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size); |
| 31 void (*add_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size); | |
| 255 | 32 void (*gmc1)(UINT8 *dst, UINT8 *src, int srcStride, int h, int x16, int y16, int rounder); |
| 296 | 33 void (*clear_blocks)(DCTELEM *blocks); |
| 612 | 34 int (*pix_sum)(UINT8 * pix, int line_size); |
| 35 int (*pix_norm1)(UINT8 * pix, int line_size); | |
| 0 | 36 |
| 37 op_pixels_abs_func pix_abs16x16; | |
| 38 op_pixels_abs_func pix_abs16x16_x2; | |
| 39 op_pixels_abs_func pix_abs16x16_y2; | |
| 40 op_pixels_abs_func pix_abs16x16_xy2; | |
| 41 | |
| 294 | 42 op_pixels_abs_func pix_abs8x8; |
| 43 op_pixels_abs_func pix_abs8x8_x2; | |
| 44 op_pixels_abs_func pix_abs8x8_y2; | |
| 45 op_pixels_abs_func pix_abs8x8_xy2; | |
| 46 | |
| 50 | 47 UINT8 cropTbl[256 + 2 * MAX_NEG_CROP]; |
| 0 | 48 UINT32 squareTbl[512]; |
| 49 | |
|
533
3c07cf9595de
adding ff prefix to avoid global name conficts with xvid (patch by Marko Kreen <marko at l-t.ee>)
michaelni
parents:
517
diff
changeset
|
50 extern INT16 ff_mpeg1_default_intra_matrix[64]; |
|
3c07cf9595de
adding ff prefix to avoid global name conficts with xvid (patch by Marko Kreen <marko at l-t.ee>)
michaelni
parents:
517
diff
changeset
|
51 extern INT16 ff_mpeg1_default_non_intra_matrix[64]; |
|
435
9247ad420889
* compatibilized declaration with its original definition
kabi
parents:
429
diff
changeset
|
52 extern INT16 ff_mpeg4_default_intra_matrix[64]; |
|
9247ad420889
* compatibilized declaration with its original definition
kabi
parents:
429
diff
changeset
|
53 extern INT16 ff_mpeg4_default_non_intra_matrix[64]; |
| 34 | 54 |
| 55 UINT8 zigzag_direct[64] = { | |
| 56 0, 1, 8, 16, 9, 2, 3, 10, | |
| 57 17, 24, 32, 25, 18, 11, 4, 5, | |
| 58 12, 19, 26, 33, 40, 48, 41, 34, | |
| 59 27, 20, 13, 6, 7, 14, 21, 28, | |
| 60 35, 42, 49, 56, 57, 50, 43, 36, | |
| 61 29, 22, 15, 23, 30, 37, 44, 51, | |
| 62 58, 59, 52, 45, 38, 31, 39, 46, | |
| 63 53, 60, 61, 54, 47, 55, 62, 63 | |
| 64 }; | |
| 65 | |
| 220 | 66 /* not permutated inverse zigzag_direct + 1 for MMX quantizer */ |
| 67 UINT16 __align8 inv_zigzag_direct16[64]; | |
| 68 | |
| 69 /* not permutated zigzag_direct for MMX quantizer */ | |
| 70 UINT8 zigzag_direct_noperm[64]; | |
| 71 | |
| 34 | 72 UINT8 ff_alternate_horizontal_scan[64] = { |
| 73 0, 1, 2, 3, 8, 9, 16, 17, | |
| 74 10, 11, 4, 5, 6, 7, 15, 14, | |
| 75 13, 12, 19, 18, 24, 25, 32, 33, | |
| 76 26, 27, 20, 21, 22, 23, 28, 29, | |
| 77 30, 31, 34, 35, 40, 41, 48, 49, | |
| 78 42, 43, 36, 37, 38, 39, 44, 45, | |
| 79 46, 47, 50, 51, 56, 57, 58, 59, | |
| 80 52, 53, 54, 55, 60, 61, 62, 63, | |
| 81 }; | |
| 82 | |
| 83 UINT8 ff_alternate_vertical_scan[64] = { | |
| 84 0, 8, 16, 24, 1, 9, 2, 10, | |
| 85 17, 25, 32, 40, 48, 56, 57, 49, | |
| 86 41, 33, 26, 18, 3, 11, 4, 12, | |
| 87 19, 27, 34, 42, 50, 58, 35, 43, | |
| 88 51, 59, 20, 28, 5, 13, 6, 14, | |
| 89 21, 29, 36, 44, 52, 60, 37, 45, | |
| 90 53, 61, 22, 30, 7, 15, 23, 31, | |
| 91 38, 46, 54, 62, 39, 47, 55, 63, | |
| 92 }; | |
| 93 | |
|
320
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
312
diff
changeset
|
94 #ifdef SIMPLE_IDCT |
|
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
312
diff
changeset
|
95 |
| 209 | 96 /* Input permutation for the simple_idct_mmx */ |
|
190
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
97 static UINT8 simple_mmx_permutation[64]={ |
| 209 | 98 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, |
| 99 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D, | |
| 100 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D, | |
| 101 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F, | |
| 102 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F, | |
| 103 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D, | |
| 104 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, | |
| 105 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, | |
|
190
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
106 }; |
|
320
cda7d0857baf
- ME setting moved to AVCodecContext/MpegEncContext, no longer a global.
pulento
parents:
312
diff
changeset
|
107 #endif |
|
190
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
108 |
| 220 | 109 /* a*inverse[b]>>32 == a/b for all 0<=a<=65536 && 2<=b<=255 */ |
| 110 UINT32 inverse[256]={ | |
| 111 0, 4294967295U,2147483648U,1431655766, 1073741824, 858993460, 715827883, 613566757, | |
| 112 536870912, 477218589, 429496730, 390451573, 357913942, 330382100, 306783379, 286331154, | |
| 113 268435456, 252645136, 238609295, 226050911, 214748365, 204522253, 195225787, 186737709, | |
| 114 178956971, 171798692, 165191050, 159072863, 153391690, 148102321, 143165577, 138547333, | |
| 115 134217728, 130150525, 126322568, 122713352, 119304648, 116080198, 113025456, 110127367, | |
| 116 107374183, 104755300, 102261127, 99882961, 97612894, 95443718, 93368855, 91382283, | |
| 117 89478486, 87652394, 85899346, 84215046, 82595525, 81037119, 79536432, 78090315, | |
| 118 76695845, 75350304, 74051161, 72796056, 71582789, 70409300, 69273667, 68174085, | |
| 119 67108864, 66076420, 65075263, 64103990, 63161284, 62245903, 61356676, 60492498, | |
| 120 59652324, 58835169, 58040099, 57266231, 56512728, 55778797, 55063684, 54366675, | |
| 121 53687092, 53024288, 52377650, 51746594, 51130564, 50529028, 49941481, 49367441, | |
| 122 48806447, 48258060, 47721859, 47197443, 46684428, 46182445, 45691142, 45210183, | |
| 123 44739243, 44278014, 43826197, 43383509, 42949673, 42524429, 42107523, 41698712, | |
| 124 41297763, 40904451, 40518560, 40139882, 39768216, 39403370, 39045158, 38693400, | |
| 125 38347923, 38008561, 37675152, 37347542, 37025581, 36709123, 36398028, 36092163, | |
| 126 35791395, 35495598, 35204650, 34918434, 34636834, 34359739, 34087043, 33818641, | |
| 127 33554432, 33294321, 33038210, 32786010, 32537632, 32292988, 32051995, 31814573, | |
| 128 31580642, 31350127, 31122952, 30899046, 30678338, 30460761, 30246249, 30034737, | |
| 129 29826162, 29620465, 29417585, 29217465, 29020050, 28825284, 28633116, 28443493, | |
| 130 28256364, 28071682, 27889399, 27709467, 27531842, 27356480, 27183338, 27012373, | |
| 131 26843546, 26676816, 26512144, 26349493, 26188825, 26030105, 25873297, 25718368, | |
| 132 25565282, 25414008, 25264514, 25116768, 24970741, 24826401, 24683721, 24542671, | |
| 133 24403224, 24265352, 24129030, 23994231, 23860930, 23729102, 23598722, 23469767, | |
| 134 23342214, 23216040, 23091223, 22967740, 22845571, 22724695, 22605092, 22486740, | |
| 135 22369622, 22253717, 22139007, 22025474, 21913099, 21801865, 21691755, 21582751, | |
| 136 21474837, 21367997, 21262215, 21157475, 21053762, 20951060, 20849356, 20748635, | |
| 137 20648882, 20550083, 20452226, 20355296, 20259280, 20164166, 20069941, 19976593, | |
| 138 19884108, 19792477, 19701685, 19611723, 19522579, 19434242, 19346700, 19259944, | |
| 139 19173962, 19088744, 19004281, 18920561, 18837576, 18755316, 18673771, 18592933, | |
| 140 18512791, 18433337, 18354562, 18276457, 18199014, 18122225, 18046082, 17970575, | |
| 141 17895698, 17821442, 17747799, 17674763, 17602325, 17530479, 17459217, 17388532, | |
| 142 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010, | |
| 143 }; | |
| 144 | |
| 200 | 145 /* used to skip zeros at the end */ |
| 146 UINT8 zigzag_end[64]; | |
| 147 | |
|
190
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
148 UINT8 permutation[64]; |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
149 //UINT8 invPermutation[64]; |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
150 |
| 468 | 151 static void build_zigzag_end(void) |
| 200 | 152 { |
| 153 int lastIndex; | |
| 154 int lastIndexAfterPerm=0; | |
| 155 for(lastIndex=0; lastIndex<64; lastIndex++) | |
| 156 { | |
| 157 if(zigzag_direct[lastIndex] > lastIndexAfterPerm) | |
| 158 lastIndexAfterPerm= zigzag_direct[lastIndex]; | |
| 159 zigzag_end[lastIndex]= lastIndexAfterPerm + 1; | |
| 160 } | |
| 161 } | |
| 162 | |
| 612 | 163 int pix_sum_c(UINT8 * pix, int line_size) |
| 164 { | |
| 165 int s, i, j; | |
| 166 | |
| 167 s = 0; | |
| 168 for (i = 0; i < 16; i++) { | |
| 169 for (j = 0; j < 16; j += 8) { | |
| 170 s += pix[0]; | |
| 171 s += pix[1]; | |
| 172 s += pix[2]; | |
| 173 s += pix[3]; | |
| 174 s += pix[4]; | |
| 175 s += pix[5]; | |
| 176 s += pix[6]; | |
| 177 s += pix[7]; | |
| 178 pix += 8; | |
| 179 } | |
| 180 pix += line_size - 16; | |
| 181 } | |
| 182 return s; | |
| 183 } | |
| 184 | |
| 185 int pix_norm1_c(UINT8 * pix, int line_size) | |
| 186 { | |
| 187 int s, i, j; | |
| 188 UINT32 *sq = squareTbl + 256; | |
| 189 | |
| 190 s = 0; | |
| 191 for (i = 0; i < 16; i++) { | |
| 192 for (j = 0; j < 16; j += 8) { | |
| 193 s += sq[pix[0]]; | |
| 194 s += sq[pix[1]]; | |
| 195 s += sq[pix[2]]; | |
| 196 s += sq[pix[3]]; | |
| 197 s += sq[pix[4]]; | |
| 198 s += sq[pix[5]]; | |
| 199 s += sq[pix[6]]; | |
| 200 s += sq[pix[7]]; | |
| 201 pix += 8; | |
| 202 } | |
| 203 pix += line_size - 16; | |
| 204 } | |
| 205 return s; | |
| 206 } | |
| 207 | |
| 208 | |
| 516 | 209 void get_pixels_c(DCTELEM *restrict block, const UINT8 *pixels, int line_size) |
| 0 | 210 { |
| 211 int i; | |
| 212 | |
| 213 /* read the pixels */ | |
| 214 for(i=0;i<8;i++) { | |
| 516 | 215 block[0] = pixels[0]; |
| 216 block[1] = pixels[1]; | |
| 217 block[2] = pixels[2]; | |
| 218 block[3] = pixels[3]; | |
| 219 block[4] = pixels[4]; | |
| 220 block[5] = pixels[5]; | |
| 221 block[6] = pixels[6]; | |
| 222 block[7] = pixels[7]; | |
| 223 pixels += line_size; | |
| 224 block += 8; | |
| 0 | 225 } |
| 226 } | |
| 227 | |
| 516 | 228 void diff_pixels_c(DCTELEM *restrict block, const UINT8 *s1, const UINT8 *s2, |
| 229 int stride){ | |
| 324 | 230 int i; |
| 231 | |
| 232 /* read the pixels */ | |
| 233 for(i=0;i<8;i++) { | |
| 516 | 234 block[0] = s1[0] - s2[0]; |
| 235 block[1] = s1[1] - s2[1]; | |
| 236 block[2] = s1[2] - s2[2]; | |
| 237 block[3] = s1[3] - s2[3]; | |
| 238 block[4] = s1[4] - s2[4]; | |
| 239 block[5] = s1[5] - s2[5]; | |
| 240 block[6] = s1[6] - s2[6]; | |
| 241 block[7] = s1[7] - s2[7]; | |
| 324 | 242 s1 += stride; |
| 243 s2 += stride; | |
| 516 | 244 block += 8; |
| 324 | 245 } |
| 246 } | |
| 247 | |
| 248 | |
| 516 | 249 void put_pixels_clamped_c(const DCTELEM *block, UINT8 *restrict pixels, |
| 250 int line_size) | |
| 0 | 251 { |
| 252 int i; | |
| 253 UINT8 *cm = cropTbl + MAX_NEG_CROP; | |
| 254 | |
| 255 /* read the pixels */ | |
| 256 for(i=0;i<8;i++) { | |
| 516 | 257 pixels[0] = cm[block[0]]; |
| 258 pixels[1] = cm[block[1]]; | |
| 259 pixels[2] = cm[block[2]]; | |
| 260 pixels[3] = cm[block[3]]; | |
| 261 pixels[4] = cm[block[4]]; | |
| 262 pixels[5] = cm[block[5]]; | |
| 263 pixels[6] = cm[block[6]]; | |
| 264 pixels[7] = cm[block[7]]; | |
| 265 | |
| 266 pixels += line_size; | |
| 267 block += 8; | |
| 0 | 268 } |
| 269 } | |
| 270 | |
| 516 | 271 void add_pixels_clamped_c(const DCTELEM *block, UINT8 *restrict pixels, |
| 272 int line_size) | |
| 0 | 273 { |
| 274 int i; | |
| 275 UINT8 *cm = cropTbl + MAX_NEG_CROP; | |
| 276 | |
| 277 /* read the pixels */ | |
| 278 for(i=0;i<8;i++) { | |
| 516 | 279 pixels[0] = cm[pixels[0] + block[0]]; |
| 280 pixels[1] = cm[pixels[1] + block[1]]; | |
| 281 pixels[2] = cm[pixels[2] + block[2]]; | |
| 282 pixels[3] = cm[pixels[3] + block[3]]; | |
| 283 pixels[4] = cm[pixels[4] + block[4]]; | |
| 284 pixels[5] = cm[pixels[5] + block[5]]; | |
| 285 pixels[6] = cm[pixels[6] + block[6]]; | |
| 286 pixels[7] = cm[pixels[7] + block[7]]; | |
| 287 pixels += line_size; | |
| 288 block += 8; | |
| 0 | 289 } |
| 290 } | |
| 385 | 291 #if 0 |
| 292 | |
| 293 #define PIXOP2(OPNAME, OP) \ | |
| 651 | 294 static void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 295 {\ |
| 296 int i;\ | |
| 297 for(i=0; i<h; i++){\ | |
| 298 OP(*((uint64_t*)block), LD64(pixels));\ | |
| 299 pixels+=line_size;\ | |
| 300 block +=line_size;\ | |
| 301 }\ | |
| 302 }\ | |
| 303 \ | |
| 651 | 304 static void OPNAME ## _no_rnd_pixels_x2(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 305 {\ |
| 306 int i;\ | |
| 307 for(i=0; i<h; i++){\ | |
| 308 const uint64_t a= LD64(pixels );\ | |
| 309 const uint64_t b= LD64(pixels+1);\ | |
| 310 OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\ | |
| 311 pixels+=line_size;\ | |
| 312 block +=line_size;\ | |
| 313 }\ | |
| 314 }\ | |
| 315 \ | |
| 651 | 316 static void OPNAME ## _pixels_x2(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 317 {\ |
| 318 int i;\ | |
| 319 for(i=0; i<h; i++){\ | |
| 320 const uint64_t a= LD64(pixels );\ | |
| 321 const uint64_t b= LD64(pixels+1);\ | |
| 322 OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\ | |
| 323 pixels+=line_size;\ | |
| 324 block +=line_size;\ | |
| 325 }\ | |
| 326 }\ | |
| 327 \ | |
| 651 | 328 static void OPNAME ## _no_rnd_pixels_y2(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 329 {\ |
| 330 int i;\ | |
| 331 for(i=0; i<h; i++){\ | |
| 332 const uint64_t a= LD64(pixels );\ | |
| 333 const uint64_t b= LD64(pixels+line_size);\ | |
| 334 OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\ | |
| 335 pixels+=line_size;\ | |
| 336 block +=line_size;\ | |
| 337 }\ | |
| 338 }\ | |
| 339 \ | |
| 651 | 340 static void OPNAME ## _pixels_y2(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 341 {\ |
| 342 int i;\ | |
| 343 for(i=0; i<h; i++){\ | |
| 344 const uint64_t a= LD64(pixels );\ | |
| 345 const uint64_t b= LD64(pixels+line_size);\ | |
| 346 OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\ | |
| 347 pixels+=line_size;\ | |
| 348 block +=line_size;\ | |
| 349 }\ | |
| 350 }\ | |
| 351 \ | |
| 651 | 352 static void OPNAME ## _pixels_xy2(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 353 {\ |
| 354 int i;\ | |
| 355 const uint64_t a= LD64(pixels );\ | |
| 356 const uint64_t b= LD64(pixels+1);\ | |
| 357 uint64_t l0= (a&0x0303030303030303ULL)\ | |
| 358 + (b&0x0303030303030303ULL)\ | |
| 359 + 0x0202020202020202ULL;\ | |
| 360 uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | |
| 361 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | |
| 362 uint64_t l1,h1;\ | |
| 363 \ | |
| 364 pixels+=line_size;\ | |
| 365 for(i=0; i<h; i+=2){\ | |
| 366 uint64_t a= LD64(pixels );\ | |
| 367 uint64_t b= LD64(pixels+1);\ | |
| 368 l1= (a&0x0303030303030303ULL)\ | |
| 369 + (b&0x0303030303030303ULL);\ | |
| 370 h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | |
| 371 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | |
| 372 OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ | |
| 373 pixels+=line_size;\ | |
| 374 block +=line_size;\ | |
| 375 a= LD64(pixels );\ | |
| 376 b= LD64(pixels+1);\ | |
| 377 l0= (a&0x0303030303030303ULL)\ | |
| 378 + (b&0x0303030303030303ULL)\ | |
| 379 + 0x0202020202020202ULL;\ | |
| 380 h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | |
| 381 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | |
| 382 OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ | |
| 383 pixels+=line_size;\ | |
| 384 block +=line_size;\ | |
| 385 }\ | |
| 386 }\ | |
| 387 \ | |
| 651 | 388 static void OPNAME ## _no_rnd_pixels_xy2(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 389 {\ |
| 390 int i;\ | |
| 391 const uint64_t a= LD64(pixels );\ | |
| 392 const uint64_t b= LD64(pixels+1);\ | |
| 393 uint64_t l0= (a&0x0303030303030303ULL)\ | |
| 394 + (b&0x0303030303030303ULL)\ | |
| 395 + 0x0101010101010101ULL;\ | |
| 396 uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | |
| 397 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | |
| 398 uint64_t l1,h1;\ | |
| 399 \ | |
| 400 pixels+=line_size;\ | |
| 401 for(i=0; i<h; i+=2){\ | |
| 402 uint64_t a= LD64(pixels );\ | |
| 403 uint64_t b= LD64(pixels+1);\ | |
| 404 l1= (a&0x0303030303030303ULL)\ | |
| 405 + (b&0x0303030303030303ULL);\ | |
| 406 h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | |
| 407 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | |
| 408 OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ | |
| 409 pixels+=line_size;\ | |
| 410 block +=line_size;\ | |
| 411 a= LD64(pixels );\ | |
| 412 b= LD64(pixels+1);\ | |
| 413 l0= (a&0x0303030303030303ULL)\ | |
| 414 + (b&0x0303030303030303ULL)\ | |
| 415 + 0x0101010101010101ULL;\ | |
| 416 h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | |
| 417 + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | |
| 418 OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ | |
| 419 pixels+=line_size;\ | |
| 420 block +=line_size;\ | |
| 421 }\ | |
| 422 }\ | |
| 423 \ | |
| 651 | 424 CALL_2X_PIXELS(OPNAME ## _pixels16 , OPNAME ## _pixels , 8)\ |
| 425 CALL_2X_PIXELS(OPNAME ## _pixels16_x2 , OPNAME ## _pixels_x2 , 8)\ | |
| 426 CALL_2X_PIXELS(OPNAME ## _pixels16_y2 , OPNAME ## _pixels_y2 , 8)\ | |
| 427 CALL_2X_PIXELS(OPNAME ## _pixels16_xy2, OPNAME ## _pixels_xy2, 8)\ | |
| 428 CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2 , OPNAME ## _no_rnd_pixels_x2 , 8)\ | |
| 429 CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2 , OPNAME ## _no_rnd_pixels_y2 , 8)\ | |
| 430 CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2, OPNAME ## _no_rnd_pixels_xy2, 8)\ | |
| 431 \ | |
| 432 void (*OPNAME ## _pixels_tab[2][4])(uint8_t *block, const uint8_t *pixels, int line_size, int h) = {\ | |
| 433 {\ | |
| 434 OPNAME ## _pixels,\ | |
| 435 OPNAME ## _pixels_x2,\ | |
| 436 OPNAME ## _pixels_y2,\ | |
| 437 OPNAME ## _pixels_xy2},\ | |
| 438 {\ | |
| 439 OPNAME ## _pixels16,\ | |
| 440 OPNAME ## _pixels16_x2,\ | |
| 441 OPNAME ## _pixels16_y2,\ | |
| 442 OPNAME ## _pixels16_xy2}\ | |
| 385 | 443 };\ |
| 444 \ | |
| 651 | 445 void (*OPNAME ## _no_rnd_pixels_tab[2][4])(uint8_t *block, const uint8_t *pixels, int line_size, int h) = {\ |
| 446 {\ | |
| 447 OPNAME ## _pixels,\ | |
| 448 OPNAME ## _no_rnd_pixels_x2,\ | |
| 449 OPNAME ## _no_rnd_pixels_y2,\ | |
| 450 OPNAME ## _no_rnd_pixels_xy2},\ | |
| 451 {\ | |
| 452 OPNAME ## _pixels16,\ | |
| 453 OPNAME ## _no_rnd_pixels16_x2,\ | |
| 454 OPNAME ## _no_rnd_pixels16_y2,\ | |
| 455 OPNAME ## _no_rnd_pixels16_xy2}\ | |
| 385 | 456 }; |
| 457 | |
| 458 #define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEFEFEFEFEULL)>>1) ) | |
| 459 #else // 64 bit variant | |
| 460 | |
| 461 #define PIXOP2(OPNAME, OP) \ | |
| 651 | 462 static void OPNAME ## _pixels8(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ |
| 385 | 463 int i;\ |
| 464 for(i=0; i<h; i++){\ | |
| 465 OP(*((uint32_t*)(block )), LD32(pixels ));\ | |
| 466 OP(*((uint32_t*)(block+4)), LD32(pixels+4));\ | |
| 467 pixels+=line_size;\ | |
| 468 block +=line_size;\ | |
| 469 }\ | |
| 470 }\ | |
| 651 | 471 static inline void OPNAME ## _no_rnd_pixels8(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ |
| 472 OPNAME ## _pixels8(block, pixels, line_size, h);\ | |
| 473 }\ | |
| 385 | 474 \ |
| 651 | 475 static inline void OPNAME ## _no_rnd_pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ |
| 476 int src_stride1, int src_stride2, int h){\ | |
| 385 | 477 int i;\ |
| 478 for(i=0; i<h; i++){\ | |
| 651 | 479 uint32_t a,b;\ |
| 480 a= LD32(&src1[i*src_stride1 ]);\ | |
| 481 b= LD32(&src2[i*src_stride2 ]);\ | |
| 482 OP(*((uint32_t*)&dst[i*dst_stride ]), (a&b) + (((a^b)&0xFEFEFEFEUL)>>1));\ | |
| 483 a= LD32(&src1[i*src_stride1+4]);\ | |
| 484 b= LD32(&src2[i*src_stride2+4]);\ | |
| 485 OP(*((uint32_t*)&dst[i*dst_stride+4]), (a&b) + (((a^b)&0xFEFEFEFEUL)>>1));\ | |
| 385 | 486 }\ |
| 487 }\ | |
| 488 \ | |
| 651 | 489 static inline void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ |
| 490 int src_stride1, int src_stride2, int h){\ | |
| 385 | 491 int i;\ |
| 492 for(i=0; i<h; i++){\ | |
| 651 | 493 uint32_t a,b;\ |
| 494 a= LD32(&src1[i*src_stride1 ]);\ | |
| 495 b= LD32(&src2[i*src_stride2 ]);\ | |
| 496 OP(*((uint32_t*)&dst[i*dst_stride ]), (a|b) - (((a^b)&0xFEFEFEFEUL)>>1));\ | |
| 497 a= LD32(&src1[i*src_stride1+4]);\ | |
| 498 b= LD32(&src2[i*src_stride2+4]);\ | |
| 499 OP(*((uint32_t*)&dst[i*dst_stride+4]), (a|b) - (((a^b)&0xFEFEFEFEUL)>>1));\ | |
| 385 | 500 }\ |
| 501 }\ | |
| 502 \ | |
| 651 | 503 static inline void OPNAME ## _pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ |
| 504 int src_stride1, int src_stride2, int h){\ | |
| 505 OPNAME ## _pixels8_l2(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\ | |
| 506 OPNAME ## _pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\ | |
| 507 }\ | |
| 508 \ | |
| 509 static inline void OPNAME ## _no_rnd_pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ | |
| 510 int src_stride1, int src_stride2, int h){\ | |
| 511 OPNAME ## _no_rnd_pixels8_l2(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\ | |
| 512 OPNAME ## _no_rnd_pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\ | |
| 513 }\ | |
| 514 \ | |
| 515 static inline void OPNAME ## _no_rnd_pixels8_x2(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | |
| 516 OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\ | |
| 517 }\ | |
| 518 \ | |
| 519 static inline void OPNAME ## _pixels8_x2(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | |
| 520 OPNAME ## _pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\ | |
| 521 }\ | |
| 522 \ | |
| 523 static inline void OPNAME ## _no_rnd_pixels8_y2(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | |
| 524 OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ | |
| 525 }\ | |
| 526 \ | |
| 527 static inline void OPNAME ## _pixels8_y2(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | |
| 528 OPNAME ## _pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ | |
| 385 | 529 }\ |
| 530 \ | |
| 651 | 531 static inline void OPNAME ## _pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\ |
| 532 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ | |
| 533 int i;\ | |
| 534 for(i=0; i<h; i++){\ | |
| 535 uint32_t a, b, c, d, l0, l1, h0, h1;\ | |
| 536 a= LD32(&src1[i*src_stride1]);\ | |
| 537 b= LD32(&src2[i*src_stride2]);\ | |
| 538 c= LD32(&src3[i*src_stride3]);\ | |
| 539 d= LD32(&src4[i*src_stride4]);\ | |
| 540 l0= (a&0x03030303UL)\ | |
| 541 + (b&0x03030303UL)\ | |
| 542 + 0x02020202UL;\ | |
| 543 h0= ((a&0xFCFCFCFCUL)>>2)\ | |
| 544 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 545 l1= (c&0x03030303UL)\ | |
| 546 + (d&0x03030303UL);\ | |
| 547 h1= ((c&0xFCFCFCFCUL)>>2)\ | |
| 548 + ((d&0xFCFCFCFCUL)>>2);\ | |
| 549 OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | |
| 550 a= LD32(&src1[i*src_stride1+4]);\ | |
| 551 b= LD32(&src2[i*src_stride2+4]);\ | |
| 552 c= LD32(&src3[i*src_stride3+4]);\ | |
| 553 d= LD32(&src4[i*src_stride4+4]);\ | |
| 554 l0= (a&0x03030303UL)\ | |
| 555 + (b&0x03030303UL)\ | |
| 556 + 0x02020202UL;\ | |
| 557 h0= ((a&0xFCFCFCFCUL)>>2)\ | |
| 558 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 559 l1= (c&0x03030303UL)\ | |
| 560 + (d&0x03030303UL);\ | |
| 561 h1= ((c&0xFCFCFCFCUL)>>2)\ | |
| 562 + ((d&0xFCFCFCFCUL)>>2);\ | |
| 563 OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | |
| 564 }\ | |
| 565 }\ | |
| 566 static inline void OPNAME ## _no_rnd_pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\ | |
| 567 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ | |
| 385 | 568 int i;\ |
| 569 for(i=0; i<h; i++){\ | |
| 651 | 570 uint32_t a, b, c, d, l0, l1, h0, h1;\ |
| 571 a= LD32(&src1[i*src_stride1]);\ | |
| 572 b= LD32(&src2[i*src_stride2]);\ | |
| 573 c= LD32(&src3[i*src_stride3]);\ | |
| 574 d= LD32(&src4[i*src_stride4]);\ | |
| 575 l0= (a&0x03030303UL)\ | |
| 576 + (b&0x03030303UL)\ | |
| 577 + 0x01010101UL;\ | |
| 578 h0= ((a&0xFCFCFCFCUL)>>2)\ | |
| 579 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 580 l1= (c&0x03030303UL)\ | |
| 581 + (d&0x03030303UL);\ | |
| 582 h1= ((c&0xFCFCFCFCUL)>>2)\ | |
| 583 + ((d&0xFCFCFCFCUL)>>2);\ | |
| 584 OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | |
| 585 a= LD32(&src1[i*src_stride1+4]);\ | |
| 586 b= LD32(&src2[i*src_stride2+4]);\ | |
| 587 c= LD32(&src3[i*src_stride3+4]);\ | |
| 588 d= LD32(&src4[i*src_stride4+4]);\ | |
| 589 l0= (a&0x03030303UL)\ | |
| 590 + (b&0x03030303UL)\ | |
| 591 + 0x01010101UL;\ | |
| 592 h0= ((a&0xFCFCFCFCUL)>>2)\ | |
| 593 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 594 l1= (c&0x03030303UL)\ | |
| 595 + (d&0x03030303UL);\ | |
| 596 h1= ((c&0xFCFCFCFCUL)>>2)\ | |
| 597 + ((d&0xFCFCFCFCUL)>>2);\ | |
| 598 OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | |
| 385 | 599 }\ |
| 600 }\ | |
| 651 | 601 static inline void OPNAME ## _pixels16_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\ |
| 602 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ | |
| 603 OPNAME ## _pixels8_l4(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ | |
| 604 OPNAME ## _pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ | |
| 605 }\ | |
| 606 static inline void OPNAME ## _no_rnd_pixels16_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\ | |
| 607 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ | |
| 608 OPNAME ## _no_rnd_pixels8_l4(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ | |
| 609 OPNAME ## _no_rnd_pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ | |
| 610 }\ | |
| 385 | 611 \ |
| 651 | 612 static inline void OPNAME ## _pixels8_xy2(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 613 {\ |
| 614 int j;\ | |
| 615 for(j=0; j<2; j++){\ | |
| 616 int i;\ | |
| 617 const uint32_t a= LD32(pixels );\ | |
| 618 const uint32_t b= LD32(pixels+1);\ | |
| 619 uint32_t l0= (a&0x03030303UL)\ | |
| 620 + (b&0x03030303UL)\ | |
| 621 + 0x02020202UL;\ | |
| 622 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ | |
| 623 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 624 uint32_t l1,h1;\ | |
| 625 \ | |
| 626 pixels+=line_size;\ | |
| 627 for(i=0; i<h; i+=2){\ | |
| 628 uint32_t a= LD32(pixels );\ | |
| 629 uint32_t b= LD32(pixels+1);\ | |
| 630 l1= (a&0x03030303UL)\ | |
| 631 + (b&0x03030303UL);\ | |
| 632 h1= ((a&0xFCFCFCFCUL)>>2)\ | |
| 633 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 634 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | |
| 635 pixels+=line_size;\ | |
| 636 block +=line_size;\ | |
| 637 a= LD32(pixels );\ | |
| 638 b= LD32(pixels+1);\ | |
| 639 l0= (a&0x03030303UL)\ | |
| 640 + (b&0x03030303UL)\ | |
| 641 + 0x02020202UL;\ | |
| 642 h0= ((a&0xFCFCFCFCUL)>>2)\ | |
| 643 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 644 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | |
| 645 pixels+=line_size;\ | |
| 646 block +=line_size;\ | |
| 647 }\ | |
| 648 pixels+=4-line_size*(h+1);\ | |
| 649 block +=4-line_size*h;\ | |
| 650 }\ | |
| 651 }\ | |
| 652 \ | |
| 651 | 653 static inline void OPNAME ## _no_rnd_pixels8_xy2(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ |
| 385 | 654 {\ |
| 655 int j;\ | |
| 656 for(j=0; j<2; j++){\ | |
| 657 int i;\ | |
| 658 const uint32_t a= LD32(pixels );\ | |
| 659 const uint32_t b= LD32(pixels+1);\ | |
| 660 uint32_t l0= (a&0x03030303UL)\ | |
| 661 + (b&0x03030303UL)\ | |
| 662 + 0x01010101UL;\ | |
| 663 uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ | |
| 664 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 665 uint32_t l1,h1;\ | |
| 666 \ | |
| 667 pixels+=line_size;\ | |
| 668 for(i=0; i<h; i+=2){\ | |
| 669 uint32_t a= LD32(pixels );\ | |
| 670 uint32_t b= LD32(pixels+1);\ | |
| 671 l1= (a&0x03030303UL)\ | |
| 672 + (b&0x03030303UL);\ | |
| 673 h1= ((a&0xFCFCFCFCUL)>>2)\ | |
| 674 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 675 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | |
| 676 pixels+=line_size;\ | |
| 677 block +=line_size;\ | |
| 678 a= LD32(pixels );\ | |
| 679 b= LD32(pixels+1);\ | |
| 680 l0= (a&0x03030303UL)\ | |
| 681 + (b&0x03030303UL)\ | |
| 682 + 0x01010101UL;\ | |
| 683 h0= ((a&0xFCFCFCFCUL)>>2)\ | |
| 684 + ((b&0xFCFCFCFCUL)>>2);\ | |
| 685 OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | |
| 686 pixels+=line_size;\ | |
| 687 block +=line_size;\ | |
| 688 }\ | |
| 689 pixels+=4-line_size*(h+1);\ | |
| 690 block +=4-line_size*h;\ | |
| 691 }\ | |
| 692 }\ | |
| 693 \ | |
| 651 | 694 CALL_2X_PIXELS(OPNAME ## _pixels16 , OPNAME ## _pixels8 , 8)\ |
| 695 CALL_2X_PIXELS(OPNAME ## _pixels16_x2 , OPNAME ## _pixels8_x2 , 8)\ | |
| 696 CALL_2X_PIXELS(OPNAME ## _pixels16_y2 , OPNAME ## _pixels8_y2 , 8)\ | |
| 697 CALL_2X_PIXELS(OPNAME ## _pixels16_xy2, OPNAME ## _pixels8_xy2, 8)\ | |
| 698 CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16 , OPNAME ## _pixels8 , 8)\ | |
| 699 CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2 , OPNAME ## _no_rnd_pixels8_x2 , 8)\ | |
| 700 CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2 , OPNAME ## _no_rnd_pixels8_y2 , 8)\ | |
| 701 CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2, OPNAME ## _no_rnd_pixels8_xy2, 8)\ | |
| 702 \ | |
| 703 void (*OPNAME ## _pixels_tab[2][4])(uint8_t *block, const uint8_t *pixels, int line_size, int h) = {\ | |
| 704 {\ | |
| 705 OPNAME ## _pixels16,\ | |
| 706 OPNAME ## _pixels16_x2,\ | |
| 707 OPNAME ## _pixels16_y2,\ | |
| 708 OPNAME ## _pixels16_xy2},\ | |
| 709 {\ | |
| 710 OPNAME ## _pixels8,\ | |
| 711 OPNAME ## _pixels8_x2,\ | |
| 712 OPNAME ## _pixels8_y2,\ | |
| 713 OPNAME ## _pixels8_xy2},\ | |
| 385 | 714 };\ |
| 715 \ | |
| 651 | 716 void (*OPNAME ## _no_rnd_pixels_tab[2][4])(uint8_t *block, const uint8_t *pixels, int line_size, int h) = {\ |
| 717 {\ | |
| 718 OPNAME ## _pixels16,\ | |
| 719 OPNAME ## _no_rnd_pixels16_x2,\ | |
| 720 OPNAME ## _no_rnd_pixels16_y2,\ | |
| 721 OPNAME ## _no_rnd_pixels16_xy2},\ | |
| 722 {\ | |
| 723 OPNAME ## _pixels8,\ | |
| 724 OPNAME ## _no_rnd_pixels8_x2,\ | |
| 725 OPNAME ## _no_rnd_pixels8_y2,\ | |
| 726 OPNAME ## _no_rnd_pixels8_xy2},\ | |
| 385 | 727 }; |
| 651 | 728 |
| 385 | 729 #define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEUL)>>1) ) |
| 730 #endif | |
| 731 #define op_put(a, b) a = b | |
| 732 | |
| 733 PIXOP2(avg, op_avg) | |
| 734 PIXOP2(put, op_put) | |
| 735 #undef op_avg | |
| 736 #undef op_put | |
| 737 | |
|
403
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
738 #if 0 |
| 385 | 739 /* FIXME this stuff could be removed as its ot really used anymore */ |
| 0 | 740 #define PIXOP(BTYPE, OPNAME, OP, INCR) \ |
| 741 \ | |
| 742 static void OPNAME ## _pixels(BTYPE *block, const UINT8 *pixels, int line_size, int h) \ | |
| 743 { \ | |
| 744 BTYPE *p; \ | |
| 745 const UINT8 *pix; \ | |
| 746 \ | |
| 747 p = block; \ | |
| 748 pix = pixels; \ | |
| 749 do { \ | |
| 750 OP(p[0], pix[0]); \ | |
| 751 OP(p[1], pix[1]); \ | |
| 752 OP(p[2], pix[2]); \ | |
| 753 OP(p[3], pix[3]); \ | |
| 754 OP(p[4], pix[4]); \ | |
| 755 OP(p[5], pix[5]); \ | |
| 756 OP(p[6], pix[6]); \ | |
| 757 OP(p[7], pix[7]); \ | |
| 758 pix += line_size; \ | |
| 759 p += INCR; \ | |
| 760 } while (--h);; \ | |
| 761 } \ | |
| 762 \ | |
| 763 static void OPNAME ## _pixels_x2(BTYPE *block, const UINT8 *pixels, int line_size, int h) \ | |
| 764 { \ | |
| 765 BTYPE *p; \ | |
| 766 const UINT8 *pix; \ | |
| 767 \ | |
| 768 p = block; \ | |
| 769 pix = pixels; \ | |
| 770 do { \ | |
| 771 OP(p[0], avg2(pix[0], pix[1])); \ | |
| 772 OP(p[1], avg2(pix[1], pix[2])); \ | |
| 773 OP(p[2], avg2(pix[2], pix[3])); \ | |
| 774 OP(p[3], avg2(pix[3], pix[4])); \ | |
| 775 OP(p[4], avg2(pix[4], pix[5])); \ | |
| 776 OP(p[5], avg2(pix[5], pix[6])); \ | |
| 777 OP(p[6], avg2(pix[6], pix[7])); \ | |
| 778 OP(p[7], avg2(pix[7], pix[8])); \ | |
| 779 pix += line_size; \ | |
| 780 p += INCR; \ | |
| 781 } while (--h); \ | |
| 782 } \ | |
| 783 \ | |
| 784 static void OPNAME ## _pixels_y2(BTYPE *block, const UINT8 *pixels, int line_size, int h) \ | |
| 785 { \ | |
| 786 BTYPE *p; \ | |
| 787 const UINT8 *pix; \ | |
| 788 const UINT8 *pix1; \ | |
| 789 \ | |
| 790 p = block; \ | |
| 791 pix = pixels; \ | |
| 792 pix1 = pixels + line_size; \ | |
| 793 do { \ | |
| 794 OP(p[0], avg2(pix[0], pix1[0])); \ | |
| 795 OP(p[1], avg2(pix[1], pix1[1])); \ | |
| 796 OP(p[2], avg2(pix[2], pix1[2])); \ | |
| 797 OP(p[3], avg2(pix[3], pix1[3])); \ | |
| 798 OP(p[4], avg2(pix[4], pix1[4])); \ | |
| 799 OP(p[5], avg2(pix[5], pix1[5])); \ | |
| 800 OP(p[6], avg2(pix[6], pix1[6])); \ | |
| 801 OP(p[7], avg2(pix[7], pix1[7])); \ | |
| 802 pix += line_size; \ | |
| 803 pix1 += line_size; \ | |
| 804 p += INCR; \ | |
| 805 } while(--h); \ | |
| 806 } \ | |
| 807 \ | |
| 808 static void OPNAME ## _pixels_xy2(BTYPE *block, const UINT8 *pixels, int line_size, int h) \ | |
| 809 { \ | |
| 810 BTYPE *p; \ | |
| 811 const UINT8 *pix; \ | |
| 812 const UINT8 *pix1; \ | |
| 813 \ | |
| 814 p = block; \ | |
| 815 pix = pixels; \ | |
| 816 pix1 = pixels + line_size; \ | |
| 817 do { \ | |
| 818 OP(p[0], avg4(pix[0], pix[1], pix1[0], pix1[1])); \ | |
| 819 OP(p[1], avg4(pix[1], pix[2], pix1[1], pix1[2])); \ | |
| 820 OP(p[2], avg4(pix[2], pix[3], pix1[2], pix1[3])); \ | |
| 821 OP(p[3], avg4(pix[3], pix[4], pix1[3], pix1[4])); \ | |
| 822 OP(p[4], avg4(pix[4], pix[5], pix1[4], pix1[5])); \ | |
| 823 OP(p[5], avg4(pix[5], pix[6], pix1[5], pix1[6])); \ | |
| 824 OP(p[6], avg4(pix[6], pix[7], pix1[6], pix1[7])); \ | |
| 825 OP(p[7], avg4(pix[7], pix[8], pix1[7], pix1[8])); \ | |
| 826 pix += line_size; \ | |
| 827 pix1 += line_size; \ | |
| 828 p += INCR; \ | |
| 829 } while(--h); \ | |
| 830 } \ | |
| 831 \ | |
| 832 void (*OPNAME ## _pixels_tab[4])(BTYPE *block, const UINT8 *pixels, int line_size, int h) = { \ | |
| 833 OPNAME ## _pixels, \ | |
| 834 OPNAME ## _pixels_x2, \ | |
| 835 OPNAME ## _pixels_y2, \ | |
| 836 OPNAME ## _pixels_xy2, \ | |
| 837 }; | |
| 838 | |
| 839 /* rounding primitives */ | |
| 840 #define avg2(a,b) ((a+b+1)>>1) | |
| 841 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) | |
| 842 | |
| 843 #define op_avg(a, b) a = avg2(a, b) | |
| 844 #define op_sub(a, b) a -= b | |
| 612 | 845 #define op_put(a, b) a = b |
| 0 | 846 |
| 847 PIXOP(DCTELEM, sub, op_sub, 8) | |
| 612 | 848 PIXOP(uint8_t, avg, op_avg, line_size) |
| 849 PIXOP(uint8_t, put, op_put, line_size) | |
| 0 | 850 |
| 851 /* not rounding primitives */ | |
| 852 #undef avg2 | |
| 853 #undef avg4 | |
| 854 #define avg2(a,b) ((a+b)>>1) | |
| 855 #define avg4(a,b,c,d) ((a+b+c+d+1)>>2) | |
| 856 | |
| 612 | 857 PIXOP(uint8_t, avg_no_rnd, op_avg, line_size) |
| 858 PIXOP(uint8_t, put_no_rnd, op_put, line_size) | |
| 0 | 859 /* motion estimation */ |
| 860 | |
| 861 #undef avg2 | |
| 862 #undef avg4 | |
|
403
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
863 #endif |
|
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
864 |
| 0 | 865 #define avg2(a,b) ((a+b+1)>>1) |
| 866 #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) | |
| 867 | |
| 651 | 868 static void gmc1_c(UINT8 *dst, UINT8 *src, int stride, int h, int x16, int y16, int rounder) |
| 255 | 869 { |
| 870 const int A=(16-x16)*(16-y16); | |
| 871 const int B=( x16)*(16-y16); | |
| 872 const int C=(16-x16)*( y16); | |
| 873 const int D=( x16)*( y16); | |
| 874 int i; | |
| 875 rounder= 128 - rounder; | |
| 876 | |
| 877 for(i=0; i<h; i++) | |
| 878 { | |
| 651 | 879 dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8; |
| 880 dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8; | |
| 881 dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8; | |
| 882 dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8; | |
| 883 dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8; | |
| 884 dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8; | |
| 885 dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8; | |
| 886 dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8; | |
| 887 dst+= stride; | |
| 888 src+= stride; | |
| 255 | 889 } |
| 890 } | |
| 891 | |
| 651 | 892 static inline void copy_block17(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int h) |
| 255 | 893 { |
| 894 int i; | |
| 895 for(i=0; i<h; i++) | |
| 896 { | |
| 651 | 897 ST32(dst , LD32(src )); |
| 898 ST32(dst+4 , LD32(src+4 )); | |
| 899 ST32(dst+8 , LD32(src+8 )); | |
| 900 ST32(dst+12, LD32(src+12)); | |
| 901 dst[16]= src[16]; | |
| 255 | 902 dst+=dstStride; |
| 903 src+=srcStride; | |
| 904 } | |
| 905 } | |
| 906 | |
| 651 | 907 static inline void copy_block9(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int h) |
| 255 | 908 { |
| 909 int i; | |
| 651 | 910 for(i=0; i<h; i++) |
| 255 | 911 { |
| 651 | 912 ST32(dst , LD32(src )); |
| 913 ST32(dst+4 , LD32(src+4 )); | |
| 914 dst[8]= src[8]; | |
| 255 | 915 dst+=dstStride; |
| 916 src+=srcStride; | |
| 917 } | |
| 918 } | |
| 919 | |
| 651 | 920 #define QPEL_MC(r, OPNAME, RND, OP) \ |
| 921 static void OPNAME ## mpeg4_qpel8_h_lowpass(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int h){\ | |
| 922 UINT8 *cm = cropTbl + MAX_NEG_CROP;\ | |
| 923 int i;\ | |
| 924 for(i=0; i<h; i++)\ | |
| 925 {\ | |
| 926 OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\ | |
| 927 OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\ | |
| 928 OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\ | |
| 929 OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\ | |
| 930 OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\ | |
| 931 OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\ | |
| 932 OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\ | |
| 933 OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\ | |
| 934 dst+=dstStride;\ | |
| 935 src+=srcStride;\ | |
| 936 }\ | |
| 937 }\ | |
| 938 \ | |
| 939 static void OPNAME ## mpeg4_qpel8_v_lowpass(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int w){\ | |
| 940 UINT8 *cm = cropTbl + MAX_NEG_CROP;\ | |
| 941 int i;\ | |
| 942 for(i=0; i<w; i++)\ | |
| 943 {\ | |
| 944 const int src0= src[0*srcStride];\ | |
| 945 const int src1= src[1*srcStride];\ | |
| 946 const int src2= src[2*srcStride];\ | |
| 947 const int src3= src[3*srcStride];\ | |
| 948 const int src4= src[4*srcStride];\ | |
| 949 const int src5= src[5*srcStride];\ | |
| 950 const int src6= src[6*srcStride];\ | |
| 951 const int src7= src[7*srcStride];\ | |
| 952 const int src8= src[8*srcStride];\ | |
| 953 OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\ | |
| 954 OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\ | |
| 955 OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\ | |
| 956 OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\ | |
| 957 OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\ | |
| 958 OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\ | |
| 959 OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\ | |
| 960 OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\ | |
| 961 dst++;\ | |
| 962 src++;\ | |
| 963 }\ | |
| 964 }\ | |
| 965 \ | |
| 966 static void OPNAME ## mpeg4_qpel16_h_lowpass(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int h){\ | |
| 967 UINT8 *cm = cropTbl + MAX_NEG_CROP;\ | |
| 968 int i;\ | |
| 969 for(i=0; i<h; i++)\ | |
| 970 {\ | |
| 971 OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\ | |
| 972 OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\ | |
| 973 OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\ | |
| 974 OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\ | |
| 975 OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\ | |
| 976 OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\ | |
| 977 OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\ | |
| 978 OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\ | |
| 979 OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\ | |
| 980 OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\ | |
| 981 OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\ | |
| 982 OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\ | |
| 983 OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\ | |
| 984 OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\ | |
| 985 OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\ | |
| 986 OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\ | |
| 987 dst+=dstStride;\ | |
| 988 src+=srcStride;\ | |
| 989 }\ | |
| 255 | 990 }\ |
| 991 \ | |
| 651 | 992 static void OPNAME ## mpeg4_qpel16_v_lowpass(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int w){\ |
| 993 UINT8 *cm = cropTbl + MAX_NEG_CROP;\ | |
| 994 int i;\ | |
| 995 for(i=0; i<w; i++)\ | |
| 996 {\ | |
| 997 const int src0= src[0*srcStride];\ | |
| 998 const int src1= src[1*srcStride];\ | |
| 999 const int src2= src[2*srcStride];\ | |
| 1000 const int src3= src[3*srcStride];\ | |
| 1001 const int src4= src[4*srcStride];\ | |
| 1002 const int src5= src[5*srcStride];\ | |
| 1003 const int src6= src[6*srcStride];\ | |
| 1004 const int src7= src[7*srcStride];\ | |
| 1005 const int src8= src[8*srcStride];\ | |
| 1006 const int src9= src[9*srcStride];\ | |
| 1007 const int src10= src[10*srcStride];\ | |
| 1008 const int src11= src[11*srcStride];\ | |
| 1009 const int src12= src[12*srcStride];\ | |
| 1010 const int src13= src[13*srcStride];\ | |
| 1011 const int src14= src[14*srcStride];\ | |
| 1012 const int src15= src[15*srcStride];\ | |
| 1013 const int src16= src[16*srcStride];\ | |
| 1014 OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\ | |
| 1015 OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\ | |
| 1016 OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\ | |
| 1017 OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\ | |
| 1018 OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\ | |
| 1019 OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\ | |
| 1020 OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\ | |
| 1021 OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\ | |
| 1022 OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\ | |
| 1023 OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\ | |
| 1024 OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\ | |
| 1025 OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\ | |
| 1026 OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\ | |
| 1027 OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\ | |
| 1028 OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\ | |
| 1029 OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\ | |
| 1030 dst++;\ | |
| 1031 src++;\ | |
| 1032 }\ | |
| 255 | 1033 }\ |
| 1034 \ | |
| 651 | 1035 static void OPNAME ## qpel8_mc00_c (UINT8 *dst, UINT8 *src, int stride){\ |
| 1036 OPNAME ## pixels8(dst, src, stride, 8);\ | |
| 255 | 1037 }\ |
| 1038 \ | |
| 651 | 1039 static void OPNAME ## qpel8_mc10_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 255 | 1040 UINT8 half[64];\ |
| 651 | 1041 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\ |
| 1042 OPNAME ## pixels8_l2(dst, src, half, stride, stride, 8, 8);\ | |
| 1043 }\ | |
| 1044 \ | |
| 1045 static void OPNAME ## qpel8_mc20_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1046 OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\ | |
| 255 | 1047 }\ |
| 1048 \ | |
| 651 | 1049 static void OPNAME ## qpel8_mc30_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1050 UINT8 half[64];\ | |
| 1051 put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\ | |
| 1052 OPNAME ## pixels8_l2(dst, src+1, half, stride, stride, 8, 8);\ | |
| 1053 }\ | |
| 1054 \ | |
| 1055 static void OPNAME ## qpel8_mc01_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1056 UINT8 full[16*9];\ | |
| 255 | 1057 UINT8 half[64];\ |
| 651 | 1058 copy_block9(full, src, 16, stride, 9);\ |
| 1059 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16, 8);\ | |
| 1060 OPNAME ## pixels8_l2(dst, full, half, stride, 16, 8, 8);\ | |
| 1061 }\ | |
| 1062 \ | |
| 1063 static void OPNAME ## qpel8_mc02_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1064 UINT8 full[16*9];\ | |
| 1065 copy_block9(full, src, 16, stride, 9);\ | |
| 1066 OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16, 8);\ | |
| 255 | 1067 }\ |
| 1068 \ | |
| 651 | 1069 static void OPNAME ## qpel8_mc03_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1070 UINT8 full[16*9];\ | |
| 1071 UINT8 half[64];\ | |
| 1072 copy_block9(full, src, 16, stride, 9);\ | |
| 1073 put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16, 8);\ | |
| 1074 OPNAME ## pixels8_l2(dst, full+16, half, stride, 16, 8, 8);\ | |
| 1075 }\ | |
| 1076 static void OPNAME ## qpel8_mc11_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1077 UINT8 full[16*9];\ | |
| 1078 UINT8 halfH[72];\ | |
| 1079 UINT8 halfV[64];\ | |
| 1080 UINT8 halfHV[64];\ | |
| 1081 copy_block9(full, src, 16, stride, 9);\ | |
| 1082 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | |
| 1083 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16, 8);\ | |
| 1084 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8, 8);\ | |
| 1085 OPNAME ## pixels8_l4(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ | |
| 255 | 1086 }\ |
| 651 | 1087 static void OPNAME ## qpel8_mc31_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1088 UINT8 full[16*9];\ | |
| 1089 UINT8 halfH[72];\ | |
| 1090 UINT8 halfV[64];\ | |
| 1091 UINT8 halfHV[64];\ | |
| 1092 copy_block9(full, src, 16, stride, 9);\ | |
| 1093 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | |
| 1094 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16, 8);\ | |
| 1095 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8, 8);\ | |
| 1096 OPNAME ## pixels8_l4(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ | |
| 255 | 1097 }\ |
| 651 | 1098 static void OPNAME ## qpel8_mc13_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1099 UINT8 full[16*9];\ | |
| 1100 UINT8 halfH[72];\ | |
| 1101 UINT8 halfV[64];\ | |
| 1102 UINT8 halfHV[64];\ | |
| 1103 copy_block9(full, src, 16, stride, 9);\ | |
| 1104 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | |
| 1105 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16, 8);\ | |
| 1106 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8, 8);\ | |
| 1107 OPNAME ## pixels8_l4(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ | |
| 1108 }\ | |
| 1109 static void OPNAME ## qpel8_mc33_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1110 UINT8 full[16*9];\ | |
| 255 | 1111 UINT8 halfH[72];\ |
| 256 | 1112 UINT8 halfV[64];\ |
| 255 | 1113 UINT8 halfHV[64];\ |
| 651 | 1114 copy_block9(full, src, 16, stride, 9);\ |
| 1115 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\ | |
| 1116 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16, 8);\ | |
| 1117 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8, 8);\ | |
| 1118 OPNAME ## pixels8_l4(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ | |
| 255 | 1119 }\ |
| 651 | 1120 static void OPNAME ## qpel8_mc21_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1121 UINT8 halfH[72];\ | |
| 1122 UINT8 halfHV[64];\ | |
| 1123 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ | |
| 1124 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8, 8);\ | |
| 1125 OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ | |
| 1126 }\ | |
| 1127 static void OPNAME ## qpel8_mc23_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1128 UINT8 halfH[72];\ | |
| 1129 UINT8 halfHV[64];\ | |
| 1130 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ | |
| 1131 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8, 8);\ | |
| 1132 OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ | |
| 1133 }\ | |
| 1134 static void OPNAME ## qpel8_mc12_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1135 UINT8 full[16*9];\ | |
| 255 | 1136 UINT8 halfH[72];\ |
| 256 | 1137 UINT8 halfV[64];\ |
| 255 | 1138 UINT8 halfHV[64];\ |
| 651 | 1139 copy_block9(full, src, 16, stride, 9);\ |
| 1140 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | |
| 1141 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16, 8);\ | |
| 1142 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8, 8);\ | |
| 1143 OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\ | |
| 255 | 1144 }\ |
| 651 | 1145 static void OPNAME ## qpel8_mc32_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1146 UINT8 full[16*9];\ | |
| 255 | 1147 UINT8 halfH[72];\ |
| 256 | 1148 UINT8 halfV[64];\ |
| 255 | 1149 UINT8 halfHV[64];\ |
| 651 | 1150 copy_block9(full, src, 16, stride, 9);\ |
| 1151 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | |
| 1152 put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16, 8);\ | |
| 1153 put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8, 8);\ | |
| 1154 OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\ | |
| 1155 }\ | |
| 1156 static void OPNAME ## qpel8_mc22_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1157 UINT8 halfH[72];\ | |
| 1158 put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ | |
| 1159 OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8, 8);\ | |
| 1160 }\ | |
| 1161 static void OPNAME ## qpel16_mc00_c (UINT8 *dst, UINT8 *src, int stride){\ | |
| 1162 OPNAME ## pixels16(dst, src, stride, 16);\ | |
| 255 | 1163 }\ |
| 651 | 1164 \ |
| 1165 static void OPNAME ## qpel16_mc10_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1166 UINT8 half[256];\ | |
| 1167 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\ | |
| 1168 OPNAME ## pixels16_l2(dst, src, half, stride, stride, 16, 16);\ | |
| 1169 }\ | |
| 1170 \ | |
| 1171 static void OPNAME ## qpel16_mc20_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1172 OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\ | |
| 1173 }\ | |
| 1174 \ | |
| 1175 static void OPNAME ## qpel16_mc30_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1176 UINT8 half[256];\ | |
| 1177 put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\ | |
| 1178 OPNAME ## pixels16_l2(dst, src+1, half, stride, stride, 16, 16);\ | |
| 1179 }\ | |
| 1180 \ | |
| 1181 static void OPNAME ## qpel16_mc01_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1182 UINT8 full[24*17];\ | |
| 1183 UINT8 half[256];\ | |
| 1184 copy_block17(full, src, 24, stride, 17);\ | |
| 1185 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24, 16);\ | |
| 1186 OPNAME ## pixels16_l2(dst, full, half, stride, 24, 16, 16);\ | |
| 255 | 1187 }\ |
| 651 | 1188 \ |
| 1189 static void OPNAME ## qpel16_mc02_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1190 UINT8 full[24*17];\ | |
| 1191 copy_block17(full, src, 24, stride, 17);\ | |
| 1192 OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24, 16);\ | |
| 1193 }\ | |
| 1194 \ | |
| 1195 static void OPNAME ## qpel16_mc03_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1196 UINT8 full[24*17];\ | |
| 1197 UINT8 half[256];\ | |
| 1198 copy_block17(full, src, 24, stride, 17);\ | |
| 1199 put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24, 16);\ | |
| 1200 OPNAME ## pixels16_l2(dst, full+24, half, stride, 24, 16, 16);\ | |
| 255 | 1201 }\ |
| 651 | 1202 static void OPNAME ## qpel16_mc11_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1203 UINT8 full[24*17];\ | |
| 1204 UINT8 halfH[272];\ | |
| 1205 UINT8 halfV[256];\ | |
| 1206 UINT8 halfHV[256];\ | |
| 1207 copy_block17(full, src, 24, stride, 17);\ | |
| 1208 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | |
| 1209 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24, 16);\ | |
| 1210 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16, 16);\ | |
| 1211 OPNAME ## pixels16_l4(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ | |
| 1212 }\ | |
| 1213 static void OPNAME ## qpel16_mc31_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1214 UINT8 full[24*17];\ | |
| 1215 UINT8 halfH[272];\ | |
| 1216 UINT8 halfV[256];\ | |
| 1217 UINT8 halfHV[256];\ | |
| 1218 copy_block17(full, src, 24, stride, 17);\ | |
| 1219 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | |
| 1220 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24, 16);\ | |
| 1221 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16, 16);\ | |
| 1222 OPNAME ## pixels16_l4(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ | |
| 1223 }\ | |
| 1224 static void OPNAME ## qpel16_mc13_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1225 UINT8 full[24*17];\ | |
| 1226 UINT8 halfH[272];\ | |
| 1227 UINT8 halfV[256];\ | |
| 1228 UINT8 halfHV[256];\ | |
| 1229 copy_block17(full, src, 24, stride, 17);\ | |
| 1230 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | |
| 1231 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24, 16);\ | |
| 1232 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16, 16);\ | |
| 1233 OPNAME ## pixels16_l4(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ | |
| 255 | 1234 }\ |
| 651 | 1235 static void OPNAME ## qpel16_mc33_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1236 UINT8 full[24*17];\ | |
| 1237 UINT8 halfH[272];\ | |
| 1238 UINT8 halfV[256];\ | |
| 1239 UINT8 halfHV[256];\ | |
| 1240 copy_block17(full, src, 24, stride, 17);\ | |
| 1241 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\ | |
| 1242 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24, 16);\ | |
| 1243 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16, 16);\ | |
| 1244 OPNAME ## pixels16_l4(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ | |
| 1245 }\ | |
| 1246 static void OPNAME ## qpel16_mc21_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1247 UINT8 halfH[272];\ | |
| 1248 UINT8 halfHV[256];\ | |
| 1249 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ | |
| 1250 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16, 16);\ | |
| 1251 OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ | |
| 255 | 1252 }\ |
| 651 | 1253 static void OPNAME ## qpel16_mc23_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1254 UINT8 halfH[272];\ | |
| 1255 UINT8 halfHV[256];\ | |
| 1256 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ | |
| 1257 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16, 16);\ | |
| 1258 OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ | |
| 1259 }\ | |
| 1260 static void OPNAME ## qpel16_mc12_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1261 UINT8 full[24*17];\ | |
| 1262 UINT8 halfH[272];\ | |
| 1263 UINT8 halfV[256];\ | |
| 1264 UINT8 halfHV[256];\ | |
| 1265 copy_block17(full, src, 24, stride, 17);\ | |
| 1266 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | |
| 1267 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24, 16);\ | |
| 1268 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16, 16);\ | |
| 1269 OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\ | |
| 255 | 1270 }\ |
| 651 | 1271 static void OPNAME ## qpel16_mc32_c(UINT8 *dst, UINT8 *src, int stride){\ |
| 1272 UINT8 full[24*17];\ | |
| 1273 UINT8 halfH[272];\ | |
| 1274 UINT8 halfV[256];\ | |
| 1275 UINT8 halfHV[256];\ | |
| 1276 copy_block17(full, src, 24, stride, 17);\ | |
| 1277 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | |
| 1278 put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24, 16);\ | |
| 1279 put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16, 16);\ | |
| 1280 OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\ | |
| 1281 }\ | |
| 1282 static void OPNAME ## qpel16_mc22_c(UINT8 *dst, UINT8 *src, int stride){\ | |
| 1283 UINT8 halfH[272];\ | |
| 1284 put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ | |
| 1285 OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16, 16);\ | |
| 1286 }\ | |
| 1287 qpel_mc_func OPNAME ## qpel_pixels_tab[2][16]={ \ | |
| 1288 {\ | |
| 1289 OPNAME ## qpel16_mc00_c, \ | |
| 1290 OPNAME ## qpel16_mc10_c, \ | |
| 1291 OPNAME ## qpel16_mc20_c, \ | |
| 1292 OPNAME ## qpel16_mc30_c, \ | |
| 1293 OPNAME ## qpel16_mc01_c, \ | |
| 1294 OPNAME ## qpel16_mc11_c, \ | |
| 1295 OPNAME ## qpel16_mc21_c, \ | |
| 1296 OPNAME ## qpel16_mc31_c, \ | |
| 1297 OPNAME ## qpel16_mc02_c, \ | |
| 1298 OPNAME ## qpel16_mc12_c, \ | |
| 1299 OPNAME ## qpel16_mc22_c, \ | |
| 1300 OPNAME ## qpel16_mc32_c, \ | |
| 1301 OPNAME ## qpel16_mc03_c, \ | |
| 1302 OPNAME ## qpel16_mc13_c, \ | |
| 1303 OPNAME ## qpel16_mc23_c, \ | |
| 1304 OPNAME ## qpel16_mc33_c, \ | |
| 1305 },{\ | |
| 1306 OPNAME ## qpel8_mc00_c, \ | |
| 1307 OPNAME ## qpel8_mc10_c, \ | |
| 1308 OPNAME ## qpel8_mc20_c, \ | |
| 1309 OPNAME ## qpel8_mc30_c, \ | |
| 1310 OPNAME ## qpel8_mc01_c, \ | |
| 1311 OPNAME ## qpel8_mc11_c, \ | |
| 1312 OPNAME ## qpel8_mc21_c, \ | |
| 1313 OPNAME ## qpel8_mc31_c, \ | |
| 1314 OPNAME ## qpel8_mc02_c, \ | |
| 1315 OPNAME ## qpel8_mc12_c, \ | |
| 1316 OPNAME ## qpel8_mc22_c, \ | |
| 1317 OPNAME ## qpel8_mc32_c, \ | |
| 1318 OPNAME ## qpel8_mc03_c, \ | |
| 1319 OPNAME ## qpel8_mc13_c, \ | |
| 1320 OPNAME ## qpel8_mc23_c, \ | |
| 1321 OPNAME ## qpel8_mc33_c, \ | |
| 1322 }\ | |
| 255 | 1323 }; |
| 1324 | |
| 651 | 1325 #define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1) |
| 1326 #define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1) | |
| 1327 #define op_put(a, b) a = cm[((b) + 16)>>5] | |
| 1328 #define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5] | |
| 1329 | |
| 1330 QPEL_MC(0, put_ , _ , op_put) | |
| 1331 QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd) | |
| 1332 QPEL_MC(0, avg_ , _ , op_avg) | |
| 1333 //QPEL_MC(1, avg_no_rnd , _ , op_avg) | |
| 1334 #undef op_avg | |
| 1335 #undef op_avg_no_rnd | |
| 1336 #undef op_put | |
| 1337 #undef op_put_no_rnd | |
| 255 | 1338 |
| 294 | 1339 int pix_abs16x16_c(UINT8 *pix1, UINT8 *pix2, int line_size) |
| 0 | 1340 { |
| 1341 int s, i; | |
| 1342 | |
| 1343 s = 0; | |
| 294 | 1344 for(i=0;i<16;i++) { |
| 0 | 1345 s += abs(pix1[0] - pix2[0]); |
| 1346 s += abs(pix1[1] - pix2[1]); | |
| 1347 s += abs(pix1[2] - pix2[2]); | |
| 1348 s += abs(pix1[3] - pix2[3]); | |
| 1349 s += abs(pix1[4] - pix2[4]); | |
| 1350 s += abs(pix1[5] - pix2[5]); | |
| 1351 s += abs(pix1[6] - pix2[6]); | |
| 1352 s += abs(pix1[7] - pix2[7]); | |
| 1353 s += abs(pix1[8] - pix2[8]); | |
| 1354 s += abs(pix1[9] - pix2[9]); | |
| 1355 s += abs(pix1[10] - pix2[10]); | |
| 1356 s += abs(pix1[11] - pix2[11]); | |
| 1357 s += abs(pix1[12] - pix2[12]); | |
| 1358 s += abs(pix1[13] - pix2[13]); | |
| 1359 s += abs(pix1[14] - pix2[14]); | |
| 1360 s += abs(pix1[15] - pix2[15]); | |
| 1361 pix1 += line_size; | |
| 1362 pix2 += line_size; | |
| 1363 } | |
| 1364 return s; | |
| 1365 } | |
| 1366 | |
| 294 | 1367 int pix_abs16x16_x2_c(UINT8 *pix1, UINT8 *pix2, int line_size) |
| 0 | 1368 { |
| 1369 int s, i; | |
| 1370 | |
| 1371 s = 0; | |
| 294 | 1372 for(i=0;i<16;i++) { |
| 0 | 1373 s += abs(pix1[0] - avg2(pix2[0], pix2[1])); |
| 1374 s += abs(pix1[1] - avg2(pix2[1], pix2[2])); | |
| 1375 s += abs(pix1[2] - avg2(pix2[2], pix2[3])); | |
| 1376 s += abs(pix1[3] - avg2(pix2[3], pix2[4])); | |
| 1377 s += abs(pix1[4] - avg2(pix2[4], pix2[5])); | |
| 1378 s += abs(pix1[5] - avg2(pix2[5], pix2[6])); | |
| 1379 s += abs(pix1[6] - avg2(pix2[6], pix2[7])); | |
| 1380 s += abs(pix1[7] - avg2(pix2[7], pix2[8])); | |
| 1381 s += abs(pix1[8] - avg2(pix2[8], pix2[9])); | |
| 1382 s += abs(pix1[9] - avg2(pix2[9], pix2[10])); | |
| 1383 s += abs(pix1[10] - avg2(pix2[10], pix2[11])); | |
| 1384 s += abs(pix1[11] - avg2(pix2[11], pix2[12])); | |
| 1385 s += abs(pix1[12] - avg2(pix2[12], pix2[13])); | |
| 1386 s += abs(pix1[13] - avg2(pix2[13], pix2[14])); | |
| 1387 s += abs(pix1[14] - avg2(pix2[14], pix2[15])); | |
| 1388 s += abs(pix1[15] - avg2(pix2[15], pix2[16])); | |
| 1389 pix1 += line_size; | |
| 1390 pix2 += line_size; | |
| 1391 } | |
| 1392 return s; | |
| 1393 } | |
| 1394 | |
| 294 | 1395 int pix_abs16x16_y2_c(UINT8 *pix1, UINT8 *pix2, int line_size) |
| 0 | 1396 { |
| 1397 int s, i; | |
| 1398 UINT8 *pix3 = pix2 + line_size; | |
| 1399 | |
| 1400 s = 0; | |
| 294 | 1401 for(i=0;i<16;i++) { |
| 0 | 1402 s += abs(pix1[0] - avg2(pix2[0], pix3[0])); |
| 1403 s += abs(pix1[1] - avg2(pix2[1], pix3[1])); | |
| 1404 s += abs(pix1[2] - avg2(pix2[2], pix3[2])); | |
| 1405 s += abs(pix1[3] - avg2(pix2[3], pix3[3])); | |
| 1406 s += abs(pix1[4] - avg2(pix2[4], pix3[4])); | |
| 1407 s += abs(pix1[5] - avg2(pix2[5], pix3[5])); | |
| 1408 s += abs(pix1[6] - avg2(pix2[6], pix3[6])); | |
| 1409 s += abs(pix1[7] - avg2(pix2[7], pix3[7])); | |
| 1410 s += abs(pix1[8] - avg2(pix2[8], pix3[8])); | |
| 1411 s += abs(pix1[9] - avg2(pix2[9], pix3[9])); | |
| 1412 s += abs(pix1[10] - avg2(pix2[10], pix3[10])); | |
| 1413 s += abs(pix1[11] - avg2(pix2[11], pix3[11])); | |
| 1414 s += abs(pix1[12] - avg2(pix2[12], pix3[12])); | |
| 1415 s += abs(pix1[13] - avg2(pix2[13], pix3[13])); | |
| 1416 s += abs(pix1[14] - avg2(pix2[14], pix3[14])); | |
| 1417 s += abs(pix1[15] - avg2(pix2[15], pix3[15])); | |
| 1418 pix1 += line_size; | |
| 1419 pix2 += line_size; | |
| 1420 pix3 += line_size; | |
| 1421 } | |
| 1422 return s; | |
| 1423 } | |
| 1424 | |
| 294 | 1425 int pix_abs16x16_xy2_c(UINT8 *pix1, UINT8 *pix2, int line_size) |
| 0 | 1426 { |
| 1427 int s, i; | |
| 1428 UINT8 *pix3 = pix2 + line_size; | |
| 1429 | |
| 1430 s = 0; | |
| 294 | 1431 for(i=0;i<16;i++) { |
| 0 | 1432 s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1])); |
| 1433 s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2])); | |
| 1434 s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3])); | |
| 1435 s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4])); | |
| 1436 s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5])); | |
| 1437 s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6])); | |
| 1438 s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7])); | |
| 1439 s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8])); | |
| 1440 s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9])); | |
| 1441 s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10])); | |
| 1442 s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11])); | |
| 1443 s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12])); | |
| 1444 s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13])); | |
| 1445 s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14])); | |
| 1446 s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15])); | |
| 1447 s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16])); | |
| 1448 pix1 += line_size; | |
| 1449 pix2 += line_size; | |
| 1450 pix3 += line_size; | |
| 1451 } | |
| 1452 return s; | |
| 1453 } | |
| 1454 | |
| 294 | 1455 int pix_abs8x8_c(UINT8 *pix1, UINT8 *pix2, int line_size) |
| 1456 { | |
| 1457 int s, i; | |
| 1458 | |
| 1459 s = 0; | |
| 1460 for(i=0;i<8;i++) { | |
| 1461 s += abs(pix1[0] - pix2[0]); | |
| 1462 s += abs(pix1[1] - pix2[1]); | |
| 1463 s += abs(pix1[2] - pix2[2]); | |
| 1464 s += abs(pix1[3] - pix2[3]); | |
| 1465 s += abs(pix1[4] - pix2[4]); | |
| 1466 s += abs(pix1[5] - pix2[5]); | |
| 1467 s += abs(pix1[6] - pix2[6]); | |
| 1468 s += abs(pix1[7] - pix2[7]); | |
| 1469 pix1 += line_size; | |
| 1470 pix2 += line_size; | |
| 1471 } | |
| 1472 return s; | |
| 1473 } | |
| 1474 | |
| 1475 int pix_abs8x8_x2_c(UINT8 *pix1, UINT8 *pix2, int line_size) | |
| 1476 { | |
| 1477 int s, i; | |
| 1478 | |
| 1479 s = 0; | |
| 1480 for(i=0;i<8;i++) { | |
| 1481 s += abs(pix1[0] - avg2(pix2[0], pix2[1])); | |
| 1482 s += abs(pix1[1] - avg2(pix2[1], pix2[2])); | |
| 1483 s += abs(pix1[2] - avg2(pix2[2], pix2[3])); | |
| 1484 s += abs(pix1[3] - avg2(pix2[3], pix2[4])); | |
| 1485 s += abs(pix1[4] - avg2(pix2[4], pix2[5])); | |
| 1486 s += abs(pix1[5] - avg2(pix2[5], pix2[6])); | |
| 1487 s += abs(pix1[6] - avg2(pix2[6], pix2[7])); | |
| 1488 s += abs(pix1[7] - avg2(pix2[7], pix2[8])); | |
| 1489 pix1 += line_size; | |
| 1490 pix2 += line_size; | |
| 1491 } | |
| 1492 return s; | |
| 1493 } | |
| 1494 | |
| 1495 int pix_abs8x8_y2_c(UINT8 *pix1, UINT8 *pix2, int line_size) | |
| 1496 { | |
| 1497 int s, i; | |
| 1498 UINT8 *pix3 = pix2 + line_size; | |
| 1499 | |
| 1500 s = 0; | |
| 1501 for(i=0;i<8;i++) { | |
| 1502 s += abs(pix1[0] - avg2(pix2[0], pix3[0])); | |
| 1503 s += abs(pix1[1] - avg2(pix2[1], pix3[1])); | |
| 1504 s += abs(pix1[2] - avg2(pix2[2], pix3[2])); | |
| 1505 s += abs(pix1[3] - avg2(pix2[3], pix3[3])); | |
| 1506 s += abs(pix1[4] - avg2(pix2[4], pix3[4])); | |
| 1507 s += abs(pix1[5] - avg2(pix2[5], pix3[5])); | |
| 1508 s += abs(pix1[6] - avg2(pix2[6], pix3[6])); | |
| 1509 s += abs(pix1[7] - avg2(pix2[7], pix3[7])); | |
| 1510 pix1 += line_size; | |
| 1511 pix2 += line_size; | |
| 1512 pix3 += line_size; | |
| 1513 } | |
| 1514 return s; | |
| 1515 } | |
| 1516 | |
| 1517 int pix_abs8x8_xy2_c(UINT8 *pix1, UINT8 *pix2, int line_size) | |
| 1518 { | |
| 1519 int s, i; | |
| 1520 UINT8 *pix3 = pix2 + line_size; | |
| 1521 | |
| 1522 s = 0; | |
| 1523 for(i=0;i<8;i++) { | |
| 1524 s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1])); | |
| 1525 s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2])); | |
| 1526 s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3])); | |
| 1527 s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4])); | |
| 1528 s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5])); | |
| 1529 s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6])); | |
| 1530 s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7])); | |
| 1531 s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8])); | |
| 1532 pix1 += line_size; | |
| 1533 pix2 += line_size; | |
| 1534 pix3 += line_size; | |
| 1535 } | |
| 1536 return s; | |
| 1537 } | |
| 1538 | |
| 34 | 1539 /* permute block according so that it corresponds to the MMX idct |
| 1540 order */ | |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1541 #ifdef SIMPLE_IDCT |
|
190
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1542 /* general permutation, but perhaps slightly slower */ |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1543 void block_permute(INT16 *block) |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1544 { |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1545 int i; |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1546 INT16 temp[64]; |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1547 |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1548 for(i=0; i<64; i++) temp[ block_permute_op(i) ] = block[i]; |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1549 |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1550 for(i=0; i<64; i++) block[i] = temp[i]; |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1551 } |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1552 #else |
|
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1553 |
| 34 | 1554 void block_permute(INT16 *block) |
| 1555 { | |
| 1556 int tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; | |
| 1557 int i; | |
| 1558 | |
| 1559 for(i=0;i<8;i++) { | |
| 1560 tmp1 = block[1]; | |
| 1561 tmp2 = block[2]; | |
| 1562 tmp3 = block[3]; | |
| 1563 tmp4 = block[4]; | |
| 1564 tmp5 = block[5]; | |
| 1565 tmp6 = block[6]; | |
| 1566 block[1] = tmp2; | |
| 1567 block[2] = tmp4; | |
| 1568 block[3] = tmp6; | |
| 1569 block[4] = tmp1; | |
| 1570 block[5] = tmp3; | |
| 1571 block[6] = tmp5; | |
| 1572 block += 8; | |
| 1573 } | |
| 1574 } | |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1575 #endif |
| 34 | 1576 |
| 296 | 1577 void clear_blocks_c(DCTELEM *blocks) |
| 1578 { | |
| 1579 memset(blocks, 0, sizeof(DCTELEM)*6*64); | |
| 1580 } | |
| 1581 | |
| 480 | 1582 /* XXX: those functions should be suppressed ASAP when all IDCTs are |
| 1583 converted */ | |
| 1584 void gen_idct_put(UINT8 *dest, int line_size, DCTELEM *block) | |
| 1585 { | |
| 1586 ff_idct (block); | |
| 1587 put_pixels_clamped(block, dest, line_size); | |
| 1588 } | |
| 1589 | |
| 1590 void gen_idct_add(UINT8 *dest, int line_size, DCTELEM *block) | |
| 1591 { | |
| 1592 ff_idct (block); | |
| 1593 add_pixels_clamped(block, dest, line_size); | |
| 1594 } | |
| 1595 | |
| 0 | 1596 void dsputil_init(void) |
| 1597 { | |
| 34 | 1598 int i, j; |
| 88 | 1599 int use_permuted_idct; |
| 0 | 1600 |
| 1601 for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i; | |
| 1602 for(i=0;i<MAX_NEG_CROP;i++) { | |
| 1603 cropTbl[i] = 0; | |
| 1604 cropTbl[i + MAX_NEG_CROP + 256] = 255; | |
| 1605 } | |
| 1606 | |
| 1607 for(i=0;i<512;i++) { | |
| 1608 squareTbl[i] = (i - 256) * (i - 256); | |
| 1609 } | |
| 1610 | |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1611 #ifdef SIMPLE_IDCT |
| 480 | 1612 ff_idct = NULL; |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1613 #else |
|
19
82d4c9be9873
MMX/MMXEXT iDCT support, using external functions currently defined in libmpeg2
arpi_esp
parents:
6
diff
changeset
|
1614 ff_idct = j_rev_dct; |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1615 #endif |
| 0 | 1616 get_pixels = get_pixels_c; |
| 324 | 1617 diff_pixels = diff_pixels_c; |
| 0 | 1618 put_pixels_clamped = put_pixels_clamped_c; |
| 1619 add_pixels_clamped = add_pixels_clamped_c; | |
| 255 | 1620 gmc1= gmc1_c; |
| 296 | 1621 clear_blocks= clear_blocks_c; |
| 612 | 1622 pix_sum= pix_sum_c; |
| 1623 pix_norm1= pix_norm1_c; | |
| 0 | 1624 |
| 294 | 1625 pix_abs16x16 = pix_abs16x16_c; |
| 1626 pix_abs16x16_x2 = pix_abs16x16_x2_c; | |
| 1627 pix_abs16x16_y2 = pix_abs16x16_y2_c; | |
| 0 | 1628 pix_abs16x16_xy2 = pix_abs16x16_xy2_c; |
| 294 | 1629 pix_abs8x8 = pix_abs8x8_c; |
| 1630 pix_abs8x8_x2 = pix_abs8x8_x2_c; | |
| 1631 pix_abs8x8_y2 = pix_abs8x8_y2_c; | |
| 1632 pix_abs8x8_xy2 = pix_abs8x8_xy2_c; | |
| 0 | 1633 |
| 88 | 1634 use_permuted_idct = 1; |
| 34 | 1635 |
| 2 | 1636 #ifdef HAVE_MMX |
| 0 | 1637 dsputil_init_mmx(); |
| 1638 #endif | |
| 62 | 1639 #ifdef ARCH_ARMV4L |
| 1640 dsputil_init_armv4l(); | |
| 1641 #endif | |
| 88 | 1642 #ifdef HAVE_MLIB |
| 1643 dsputil_init_mlib(); | |
| 1644 use_permuted_idct = 0; | |
| 1645 #endif | |
|
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
209
diff
changeset
|
1646 #ifdef ARCH_ALPHA |
|
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
209
diff
changeset
|
1647 dsputil_init_alpha(); |
|
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
209
diff
changeset
|
1648 use_permuted_idct = 0; |
|
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
209
diff
changeset
|
1649 #endif |
|
623
92e99e506920
first cut at altivec support on darwin patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
612
diff
changeset
|
1650 #ifdef ARCH_POWERPC |
|
638
0012f75c92bb
altivec build tidyup patch by (Brian Foley <bfoley at compsoc dot nuigalway dot ie>)
michaelni
parents:
626
diff
changeset
|
1651 dsputil_init_ppc(); |
|
626
23a093d6e450
patch by Heliodoro Tammaro <helio at interactives dot org>
michaelni
parents:
625
diff
changeset
|
1652 #endif |
| 88 | 1653 |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1654 #ifdef SIMPLE_IDCT |
| 480 | 1655 if (ff_idct == NULL) { |
| 1656 ff_idct_put = simple_idct_put; | |
| 1657 ff_idct_add = simple_idct_add; | |
| 1658 use_permuted_idct=0; | |
| 590 | 1659 } |
| 1660 #endif | |
| 1661 if(ff_idct != NULL) { | |
| 480 | 1662 ff_idct_put = gen_idct_put; |
| 1663 ff_idct_add = gen_idct_add; | |
| 1664 } | |
|
174
ac5075a55488
new IDCT code by Michael Niedermayer (michaelni@gmx.at) - #define SIMPLE_IDCT to enable
arpi_esp
parents:
88
diff
changeset
|
1665 |
|
190
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1666 if(use_permuted_idct) |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1667 #ifdef SIMPLE_IDCT |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1668 for(i=0; i<64; i++) permutation[i]= simple_mmx_permutation[i]; |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1669 #else |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1670 for(i=0; i<64; i++) permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1671 #endif |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1672 else |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1673 for(i=0; i<64; i++) permutation[i]=i; |
|
9e0e56869d05
fix for non-mmx runtimedetect encoding bugs - patch by Michael Niedermayer <michaelni@gmx.at>
uid46427
parents:
174
diff
changeset
|
1674 |
| 220 | 1675 for(i=0; i<64; i++) inv_zigzag_direct16[zigzag_direct[i]]= i+1; |
| 1676 for(i=0; i<64; i++) zigzag_direct_noperm[i]= zigzag_direct[i]; | |
| 1677 | |
| 88 | 1678 if (use_permuted_idct) { |
| 1679 /* permute for IDCT */ | |
| 1680 for(i=0;i<64;i++) { | |
| 1681 j = zigzag_direct[i]; | |
| 1682 zigzag_direct[i] = block_permute_op(j); | |
| 1683 j = ff_alternate_horizontal_scan[i]; | |
| 1684 ff_alternate_horizontal_scan[i] = block_permute_op(j); | |
| 1685 j = ff_alternate_vertical_scan[i]; | |
| 1686 ff_alternate_vertical_scan[i] = block_permute_op(j); | |
| 1687 } | |
|
533
3c07cf9595de
adding ff prefix to avoid global name conficts with xvid (patch by Marko Kreen <marko at l-t.ee>)
michaelni
parents:
517
diff
changeset
|
1688 block_permute(ff_mpeg1_default_intra_matrix); |
|
3c07cf9595de
adding ff prefix to avoid global name conficts with xvid (patch by Marko Kreen <marko at l-t.ee>)
michaelni
parents:
517
diff
changeset
|
1689 block_permute(ff_mpeg1_default_non_intra_matrix); |
| 312 | 1690 block_permute(ff_mpeg4_default_intra_matrix); |
| 1691 block_permute(ff_mpeg4_default_non_intra_matrix); | |
| 88 | 1692 } |
| 200 | 1693 |
| 1694 build_zigzag_end(); | |
| 0 | 1695 } |
|
252
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1696 |
|
403
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
1697 /* remove any non bit exact operation (testing purpose) */ |
|
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
1698 void avcodec_set_bit_exact(void) |
|
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
1699 { |
|
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
1700 #ifdef HAVE_MMX |
|
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
1701 dsputil_set_bit_exact_mmx(); |
|
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
1702 #endif |
|
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
1703 } |
|
2c3e25f4c496
removed unused stuff - added dsputil_set_bit_exact() support for easier testing
glantau
parents:
398
diff
changeset
|
1704 |
|
252
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1705 void get_psnr(UINT8 *orig_image[3], UINT8 *coded_image[3], |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1706 int orig_linesize[3], int coded_linesize, |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1707 AVCodecContext *avctx) |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1708 { |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1709 int quad, diff, x, y; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1710 UINT8 *orig, *coded; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1711 UINT32 *sq = squareTbl + 256; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1712 |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1713 quad = 0; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1714 diff = 0; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1715 |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1716 /* Luminance */ |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1717 orig = orig_image[0]; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1718 coded = coded_image[0]; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1719 |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1720 for (y=0;y<avctx->height;y++) { |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1721 for (x=0;x<avctx->width;x++) { |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1722 diff = *(orig + x) - *(coded + x); |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1723 quad += sq[diff]; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1724 } |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1725 orig += orig_linesize[0]; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1726 coded += coded_linesize; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1727 } |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1728 |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1729 avctx->psnr_y = (float) quad / (float) (avctx->width * avctx->height); |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1730 |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1731 if (avctx->psnr_y) { |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1732 avctx->psnr_y = (float) (255 * 255) / avctx->psnr_y; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1733 avctx->psnr_y = 10 * (float) log10 (avctx->psnr_y); |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1734 } else |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1735 avctx->psnr_y = 99.99; |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1736 } |
|
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
220
diff
changeset
|
1737 |
