You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3077 lines
114KB

  1. /*
  2. * DSP utils
  3. * Copyright (c) 2000, 2001 Fabrice Bellard.
  4. *
  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.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  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
  18. *
  19. * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
  20. */
  21. /**
  22. * @file dsputil.c
  23. * DSP utils
  24. */
  25. #include "avcodec.h"
  26. #include "dsputil.h"
  27. #include "mpegvideo.h"
  28. #include "simple_idct.h"
  29. #include "faandct.h"
  30. uint8_t cropTbl[256 + 2 * MAX_NEG_CROP];
  31. uint32_t squareTbl[512];
  32. const uint8_t ff_zigzag_direct[64] = {
  33. 0, 1, 8, 16, 9, 2, 3, 10,
  34. 17, 24, 32, 25, 18, 11, 4, 5,
  35. 12, 19, 26, 33, 40, 48, 41, 34,
  36. 27, 20, 13, 6, 7, 14, 21, 28,
  37. 35, 42, 49, 56, 57, 50, 43, 36,
  38. 29, 22, 15, 23, 30, 37, 44, 51,
  39. 58, 59, 52, 45, 38, 31, 39, 46,
  40. 53, 60, 61, 54, 47, 55, 62, 63
  41. };
  42. /* not permutated inverse zigzag_direct + 1 for MMX quantizer */
  43. uint16_t __align8 inv_zigzag_direct16[64];
  44. const uint8_t ff_alternate_horizontal_scan[64] = {
  45. 0, 1, 2, 3, 8, 9, 16, 17,
  46. 10, 11, 4, 5, 6, 7, 15, 14,
  47. 13, 12, 19, 18, 24, 25, 32, 33,
  48. 26, 27, 20, 21, 22, 23, 28, 29,
  49. 30, 31, 34, 35, 40, 41, 48, 49,
  50. 42, 43, 36, 37, 38, 39, 44, 45,
  51. 46, 47, 50, 51, 56, 57, 58, 59,
  52. 52, 53, 54, 55, 60, 61, 62, 63,
  53. };
  54. const uint8_t ff_alternate_vertical_scan[64] = {
  55. 0, 8, 16, 24, 1, 9, 2, 10,
  56. 17, 25, 32, 40, 48, 56, 57, 49,
  57. 41, 33, 26, 18, 3, 11, 4, 12,
  58. 19, 27, 34, 42, 50, 58, 35, 43,
  59. 51, 59, 20, 28, 5, 13, 6, 14,
  60. 21, 29, 36, 44, 52, 60, 37, 45,
  61. 53, 61, 22, 30, 7, 15, 23, 31,
  62. 38, 46, 54, 62, 39, 47, 55, 63,
  63. };
  64. /* a*inverse[b]>>32 == a/b for all 0<=a<=65536 && 2<=b<=255 */
  65. const uint32_t inverse[256]={
  66. 0, 4294967295U,2147483648U,1431655766, 1073741824, 858993460, 715827883, 613566757,
  67. 536870912, 477218589, 429496730, 390451573, 357913942, 330382100, 306783379, 286331154,
  68. 268435456, 252645136, 238609295, 226050911, 214748365, 204522253, 195225787, 186737709,
  69. 178956971, 171798692, 165191050, 159072863, 153391690, 148102321, 143165577, 138547333,
  70. 134217728, 130150525, 126322568, 122713352, 119304648, 116080198, 113025456, 110127367,
  71. 107374183, 104755300, 102261127, 99882961, 97612894, 95443718, 93368855, 91382283,
  72. 89478486, 87652394, 85899346, 84215046, 82595525, 81037119, 79536432, 78090315,
  73. 76695845, 75350304, 74051161, 72796056, 71582789, 70409300, 69273667, 68174085,
  74. 67108864, 66076420, 65075263, 64103990, 63161284, 62245903, 61356676, 60492498,
  75. 59652324, 58835169, 58040099, 57266231, 56512728, 55778797, 55063684, 54366675,
  76. 53687092, 53024288, 52377650, 51746594, 51130564, 50529028, 49941481, 49367441,
  77. 48806447, 48258060, 47721859, 47197443, 46684428, 46182445, 45691142, 45210183,
  78. 44739243, 44278014, 43826197, 43383509, 42949673, 42524429, 42107523, 41698712,
  79. 41297763, 40904451, 40518560, 40139882, 39768216, 39403370, 39045158, 38693400,
  80. 38347923, 38008561, 37675152, 37347542, 37025581, 36709123, 36398028, 36092163,
  81. 35791395, 35495598, 35204650, 34918434, 34636834, 34359739, 34087043, 33818641,
  82. 33554432, 33294321, 33038210, 32786010, 32537632, 32292988, 32051995, 31814573,
  83. 31580642, 31350127, 31122952, 30899046, 30678338, 30460761, 30246249, 30034737,
  84. 29826162, 29620465, 29417585, 29217465, 29020050, 28825284, 28633116, 28443493,
  85. 28256364, 28071682, 27889399, 27709467, 27531842, 27356480, 27183338, 27012373,
  86. 26843546, 26676816, 26512144, 26349493, 26188825, 26030105, 25873297, 25718368,
  87. 25565282, 25414008, 25264514, 25116768, 24970741, 24826401, 24683721, 24542671,
  88. 24403224, 24265352, 24129030, 23994231, 23860930, 23729102, 23598722, 23469767,
  89. 23342214, 23216040, 23091223, 22967740, 22845571, 22724695, 22605092, 22486740,
  90. 22369622, 22253717, 22139007, 22025474, 21913099, 21801865, 21691755, 21582751,
  91. 21474837, 21367997, 21262215, 21157475, 21053762, 20951060, 20849356, 20748635,
  92. 20648882, 20550083, 20452226, 20355296, 20259280, 20164166, 20069941, 19976593,
  93. 19884108, 19792477, 19701685, 19611723, 19522579, 19434242, 19346700, 19259944,
  94. 19173962, 19088744, 19004281, 18920561, 18837576, 18755316, 18673771, 18592933,
  95. 18512791, 18433337, 18354562, 18276457, 18199014, 18122225, 18046082, 17970575,
  96. 17895698, 17821442, 17747799, 17674763, 17602325, 17530479, 17459217, 17388532,
  97. 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010,
  98. };
  99. /* Input permutation for the simple_idct_mmx */
  100. static const uint8_t simple_mmx_permutation[64]={
  101. 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
  102. 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
  103. 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
  104. 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
  105. 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
  106. 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
  107. 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
  108. 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
  109. };
  110. static int pix_sum_c(uint8_t * pix, int line_size)
  111. {
  112. int s, i, j;
  113. s = 0;
  114. for (i = 0; i < 16; i++) {
  115. for (j = 0; j < 16; j += 8) {
  116. s += pix[0];
  117. s += pix[1];
  118. s += pix[2];
  119. s += pix[3];
  120. s += pix[4];
  121. s += pix[5];
  122. s += pix[6];
  123. s += pix[7];
  124. pix += 8;
  125. }
  126. pix += line_size - 16;
  127. }
  128. return s;
  129. }
  130. static int pix_norm1_c(uint8_t * pix, int line_size)
  131. {
  132. int s, i, j;
  133. uint32_t *sq = squareTbl + 256;
  134. s = 0;
  135. for (i = 0; i < 16; i++) {
  136. for (j = 0; j < 16; j += 8) {
  137. #if 0
  138. s += sq[pix[0]];
  139. s += sq[pix[1]];
  140. s += sq[pix[2]];
  141. s += sq[pix[3]];
  142. s += sq[pix[4]];
  143. s += sq[pix[5]];
  144. s += sq[pix[6]];
  145. s += sq[pix[7]];
  146. #else
  147. #if LONG_MAX > 2147483647
  148. register uint64_t x=*(uint64_t*)pix;
  149. s += sq[x&0xff];
  150. s += sq[(x>>8)&0xff];
  151. s += sq[(x>>16)&0xff];
  152. s += sq[(x>>24)&0xff];
  153. s += sq[(x>>32)&0xff];
  154. s += sq[(x>>40)&0xff];
  155. s += sq[(x>>48)&0xff];
  156. s += sq[(x>>56)&0xff];
  157. #else
  158. register uint32_t x=*(uint32_t*)pix;
  159. s += sq[x&0xff];
  160. s += sq[(x>>8)&0xff];
  161. s += sq[(x>>16)&0xff];
  162. s += sq[(x>>24)&0xff];
  163. x=*(uint32_t*)(pix+4);
  164. s += sq[x&0xff];
  165. s += sq[(x>>8)&0xff];
  166. s += sq[(x>>16)&0xff];
  167. s += sq[(x>>24)&0xff];
  168. #endif
  169. #endif
  170. pix += 8;
  171. }
  172. pix += line_size - 16;
  173. }
  174. return s;
  175. }
  176. static void bswap_buf(uint32_t *dst, uint32_t *src, int w){
  177. int i;
  178. for(i=0; i+8<=w; i+=8){
  179. dst[i+0]= bswap_32(src[i+0]);
  180. dst[i+1]= bswap_32(src[i+1]);
  181. dst[i+2]= bswap_32(src[i+2]);
  182. dst[i+3]= bswap_32(src[i+3]);
  183. dst[i+4]= bswap_32(src[i+4]);
  184. dst[i+5]= bswap_32(src[i+5]);
  185. dst[i+6]= bswap_32(src[i+6]);
  186. dst[i+7]= bswap_32(src[i+7]);
  187. }
  188. for(;i<w; i++){
  189. dst[i+0]= bswap_32(src[i+0]);
  190. }
  191. }
  192. static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size)
  193. {
  194. int s, i;
  195. uint32_t *sq = squareTbl + 256;
  196. s = 0;
  197. for (i = 0; i < 8; i++) {
  198. s += sq[pix1[0] - pix2[0]];
  199. s += sq[pix1[1] - pix2[1]];
  200. s += sq[pix1[2] - pix2[2]];
  201. s += sq[pix1[3] - pix2[3]];
  202. s += sq[pix1[4] - pix2[4]];
  203. s += sq[pix1[5] - pix2[5]];
  204. s += sq[pix1[6] - pix2[6]];
  205. s += sq[pix1[7] - pix2[7]];
  206. pix1 += line_size;
  207. pix2 += line_size;
  208. }
  209. return s;
  210. }
  211. static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size)
  212. {
  213. int s, i;
  214. uint32_t *sq = squareTbl + 256;
  215. s = 0;
  216. for (i = 0; i < 16; i++) {
  217. s += sq[pix1[ 0] - pix2[ 0]];
  218. s += sq[pix1[ 1] - pix2[ 1]];
  219. s += sq[pix1[ 2] - pix2[ 2]];
  220. s += sq[pix1[ 3] - pix2[ 3]];
  221. s += sq[pix1[ 4] - pix2[ 4]];
  222. s += sq[pix1[ 5] - pix2[ 5]];
  223. s += sq[pix1[ 6] - pix2[ 6]];
  224. s += sq[pix1[ 7] - pix2[ 7]];
  225. s += sq[pix1[ 8] - pix2[ 8]];
  226. s += sq[pix1[ 9] - pix2[ 9]];
  227. s += sq[pix1[10] - pix2[10]];
  228. s += sq[pix1[11] - pix2[11]];
  229. s += sq[pix1[12] - pix2[12]];
  230. s += sq[pix1[13] - pix2[13]];
  231. s += sq[pix1[14] - pix2[14]];
  232. s += sq[pix1[15] - pix2[15]];
  233. pix1 += line_size;
  234. pix2 += line_size;
  235. }
  236. return s;
  237. }
  238. static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
  239. {
  240. int i;
  241. /* read the pixels */
  242. for(i=0;i<8;i++) {
  243. block[0] = pixels[0];
  244. block[1] = pixels[1];
  245. block[2] = pixels[2];
  246. block[3] = pixels[3];
  247. block[4] = pixels[4];
  248. block[5] = pixels[5];
  249. block[6] = pixels[6];
  250. block[7] = pixels[7];
  251. pixels += line_size;
  252. block += 8;
  253. }
  254. }
  255. static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1,
  256. const uint8_t *s2, int stride){
  257. int i;
  258. /* read the pixels */
  259. for(i=0;i<8;i++) {
  260. block[0] = s1[0] - s2[0];
  261. block[1] = s1[1] - s2[1];
  262. block[2] = s1[2] - s2[2];
  263. block[3] = s1[3] - s2[3];
  264. block[4] = s1[4] - s2[4];
  265. block[5] = s1[5] - s2[5];
  266. block[6] = s1[6] - s2[6];
  267. block[7] = s1[7] - s2[7];
  268. s1 += stride;
  269. s2 += stride;
  270. block += 8;
  271. }
  272. }
  273. static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
  274. int line_size)
  275. {
  276. int i;
  277. uint8_t *cm = cropTbl + MAX_NEG_CROP;
  278. /* read the pixels */
  279. for(i=0;i<8;i++) {
  280. pixels[0] = cm[block[0]];
  281. pixels[1] = cm[block[1]];
  282. pixels[2] = cm[block[2]];
  283. pixels[3] = cm[block[3]];
  284. pixels[4] = cm[block[4]];
  285. pixels[5] = cm[block[5]];
  286. pixels[6] = cm[block[6]];
  287. pixels[7] = cm[block[7]];
  288. pixels += line_size;
  289. block += 8;
  290. }
  291. }
  292. static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels,
  293. int line_size)
  294. {
  295. int i;
  296. uint8_t *cm = cropTbl + MAX_NEG_CROP;
  297. /* read the pixels */
  298. for(i=0;i<8;i++) {
  299. pixels[0] = cm[pixels[0] + block[0]];
  300. pixels[1] = cm[pixels[1] + block[1]];
  301. pixels[2] = cm[pixels[2] + block[2]];
  302. pixels[3] = cm[pixels[3] + block[3]];
  303. pixels[4] = cm[pixels[4] + block[4]];
  304. pixels[5] = cm[pixels[5] + block[5]];
  305. pixels[6] = cm[pixels[6] + block[6]];
  306. pixels[7] = cm[pixels[7] + block[7]];
  307. pixels += line_size;
  308. block += 8;
  309. }
  310. }
  311. #if 0
  312. #define PIXOP2(OPNAME, OP) \
  313. static void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  314. {\
  315. int i;\
  316. for(i=0; i<h; i++){\
  317. OP(*((uint64_t*)block), LD64(pixels));\
  318. pixels+=line_size;\
  319. block +=line_size;\
  320. }\
  321. }\
  322. \
  323. static void OPNAME ## _no_rnd_pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  324. {\
  325. int i;\
  326. for(i=0; i<h; i++){\
  327. const uint64_t a= LD64(pixels );\
  328. const uint64_t b= LD64(pixels+1);\
  329. OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
  330. pixels+=line_size;\
  331. block +=line_size;\
  332. }\
  333. }\
  334. \
  335. static void OPNAME ## _pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  336. {\
  337. int i;\
  338. for(i=0; i<h; i++){\
  339. const uint64_t a= LD64(pixels );\
  340. const uint64_t b= LD64(pixels+1);\
  341. OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
  342. pixels+=line_size;\
  343. block +=line_size;\
  344. }\
  345. }\
  346. \
  347. static void OPNAME ## _no_rnd_pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  348. {\
  349. int i;\
  350. for(i=0; i<h; i++){\
  351. const uint64_t a= LD64(pixels );\
  352. const uint64_t b= LD64(pixels+line_size);\
  353. OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
  354. pixels+=line_size;\
  355. block +=line_size;\
  356. }\
  357. }\
  358. \
  359. static void OPNAME ## _pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  360. {\
  361. int i;\
  362. for(i=0; i<h; i++){\
  363. const uint64_t a= LD64(pixels );\
  364. const uint64_t b= LD64(pixels+line_size);\
  365. OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
  366. pixels+=line_size;\
  367. block +=line_size;\
  368. }\
  369. }\
  370. \
  371. static void OPNAME ## _pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  372. {\
  373. int i;\
  374. const uint64_t a= LD64(pixels );\
  375. const uint64_t b= LD64(pixels+1);\
  376. uint64_t l0= (a&0x0303030303030303ULL)\
  377. + (b&0x0303030303030303ULL)\
  378. + 0x0202020202020202ULL;\
  379. uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
  380. + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
  381. uint64_t l1,h1;\
  382. \
  383. pixels+=line_size;\
  384. for(i=0; i<h; i+=2){\
  385. uint64_t a= LD64(pixels );\
  386. uint64_t b= LD64(pixels+1);\
  387. l1= (a&0x0303030303030303ULL)\
  388. + (b&0x0303030303030303ULL);\
  389. h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
  390. + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
  391. OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
  392. pixels+=line_size;\
  393. block +=line_size;\
  394. a= LD64(pixels );\
  395. b= LD64(pixels+1);\
  396. l0= (a&0x0303030303030303ULL)\
  397. + (b&0x0303030303030303ULL)\
  398. + 0x0202020202020202ULL;\
  399. h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
  400. + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
  401. OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
  402. pixels+=line_size;\
  403. block +=line_size;\
  404. }\
  405. }\
  406. \
  407. static void OPNAME ## _no_rnd_pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  408. {\
  409. int i;\
  410. const uint64_t a= LD64(pixels );\
  411. const uint64_t b= LD64(pixels+1);\
  412. uint64_t l0= (a&0x0303030303030303ULL)\
  413. + (b&0x0303030303030303ULL)\
  414. + 0x0101010101010101ULL;\
  415. uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
  416. + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
  417. uint64_t l1,h1;\
  418. \
  419. pixels+=line_size;\
  420. for(i=0; i<h; i+=2){\
  421. uint64_t a= LD64(pixels );\
  422. uint64_t b= LD64(pixels+1);\
  423. l1= (a&0x0303030303030303ULL)\
  424. + (b&0x0303030303030303ULL);\
  425. h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
  426. + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
  427. OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
  428. pixels+=line_size;\
  429. block +=line_size;\
  430. a= LD64(pixels );\
  431. b= LD64(pixels+1);\
  432. l0= (a&0x0303030303030303ULL)\
  433. + (b&0x0303030303030303ULL)\
  434. + 0x0101010101010101ULL;\
  435. h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
  436. + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\
  437. OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
  438. pixels+=line_size;\
  439. block +=line_size;\
  440. }\
  441. }\
  442. \
  443. CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels_c , 8)\
  444. CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels_x2_c , 8)\
  445. CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels_y2_c , 8)\
  446. CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels_xy2_c, 8)\
  447. CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels_x2_c , 8)\
  448. CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels_y2_c , 8)\
  449. CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels_xy2_c, 8)
  450. #define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEFEFEFEFEULL)>>1) )
  451. #else // 64 bit variant
  452. #define PIXOP2(OPNAME, OP) \
  453. static void OPNAME ## _pixels2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  454. int i;\
  455. for(i=0; i<h; i++){\
  456. OP(*((uint16_t*)(block )), LD16(pixels ));\
  457. pixels+=line_size;\
  458. block +=line_size;\
  459. }\
  460. }\
  461. static void OPNAME ## _pixels4_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  462. int i;\
  463. for(i=0; i<h; i++){\
  464. OP(*((uint32_t*)(block )), LD32(pixels ));\
  465. pixels+=line_size;\
  466. block +=line_size;\
  467. }\
  468. }\
  469. static void OPNAME ## _pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  470. int i;\
  471. for(i=0; i<h; i++){\
  472. OP(*((uint32_t*)(block )), LD32(pixels ));\
  473. OP(*((uint32_t*)(block+4)), LD32(pixels+4));\
  474. pixels+=line_size;\
  475. block +=line_size;\
  476. }\
  477. }\
  478. static inline void OPNAME ## _no_rnd_pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  479. OPNAME ## _pixels8_c(block, pixels, line_size, h);\
  480. }\
  481. \
  482. static inline void OPNAME ## _no_rnd_pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
  483. int src_stride1, int src_stride2, int h){\
  484. int i;\
  485. for(i=0; i<h; i++){\
  486. uint32_t a,b;\
  487. a= LD32(&src1[i*src_stride1 ]);\
  488. b= LD32(&src2[i*src_stride2 ]);\
  489. OP(*((uint32_t*)&dst[i*dst_stride ]), no_rnd_avg32(a, b));\
  490. a= LD32(&src1[i*src_stride1+4]);\
  491. b= LD32(&src2[i*src_stride2+4]);\
  492. OP(*((uint32_t*)&dst[i*dst_stride+4]), no_rnd_avg32(a, b));\
  493. }\
  494. }\
  495. \
  496. static inline void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
  497. int src_stride1, int src_stride2, int h){\
  498. int i;\
  499. for(i=0; i<h; i++){\
  500. uint32_t a,b;\
  501. a= LD32(&src1[i*src_stride1 ]);\
  502. b= LD32(&src2[i*src_stride2 ]);\
  503. OP(*((uint32_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
  504. a= LD32(&src1[i*src_stride1+4]);\
  505. b= LD32(&src2[i*src_stride2+4]);\
  506. OP(*((uint32_t*)&dst[i*dst_stride+4]), rnd_avg32(a, b));\
  507. }\
  508. }\
  509. \
  510. static inline void OPNAME ## _pixels4_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
  511. int src_stride1, int src_stride2, int h){\
  512. int i;\
  513. for(i=0; i<h; i++){\
  514. uint32_t a,b;\
  515. a= LD32(&src1[i*src_stride1 ]);\
  516. b= LD32(&src2[i*src_stride2 ]);\
  517. OP(*((uint32_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
  518. }\
  519. }\
  520. \
  521. static inline void OPNAME ## _pixels2_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
  522. int src_stride1, int src_stride2, int h){\
  523. int i;\
  524. for(i=0; i<h; i++){\
  525. uint32_t a,b;\
  526. a= LD16(&src1[i*src_stride1 ]);\
  527. b= LD16(&src2[i*src_stride2 ]);\
  528. OP(*((uint16_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\
  529. }\
  530. }\
  531. \
  532. static inline void OPNAME ## _pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
  533. int src_stride1, int src_stride2, int h){\
  534. OPNAME ## _pixels8_l2(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
  535. OPNAME ## _pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\
  536. }\
  537. \
  538. static inline void OPNAME ## _no_rnd_pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
  539. int src_stride1, int src_stride2, int h){\
  540. OPNAME ## _no_rnd_pixels8_l2(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\
  541. OPNAME ## _no_rnd_pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\
  542. }\
  543. \
  544. static inline void OPNAME ## _no_rnd_pixels8_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  545. OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
  546. }\
  547. \
  548. static inline void OPNAME ## _pixels8_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  549. OPNAME ## _pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
  550. }\
  551. \
  552. static inline void OPNAME ## _no_rnd_pixels8_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  553. OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
  554. }\
  555. \
  556. static inline void OPNAME ## _pixels8_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  557. OPNAME ## _pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
  558. }\
  559. \
  560. static inline void OPNAME ## _pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
  561. int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
  562. int i;\
  563. for(i=0; i<h; i++){\
  564. uint32_t a, b, c, d, l0, l1, h0, h1;\
  565. a= LD32(&src1[i*src_stride1]);\
  566. b= LD32(&src2[i*src_stride2]);\
  567. c= LD32(&src3[i*src_stride3]);\
  568. d= LD32(&src4[i*src_stride4]);\
  569. l0= (a&0x03030303UL)\
  570. + (b&0x03030303UL)\
  571. + 0x02020202UL;\
  572. h0= ((a&0xFCFCFCFCUL)>>2)\
  573. + ((b&0xFCFCFCFCUL)>>2);\
  574. l1= (c&0x03030303UL)\
  575. + (d&0x03030303UL);\
  576. h1= ((c&0xFCFCFCFCUL)>>2)\
  577. + ((d&0xFCFCFCFCUL)>>2);\
  578. OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  579. a= LD32(&src1[i*src_stride1+4]);\
  580. b= LD32(&src2[i*src_stride2+4]);\
  581. c= LD32(&src3[i*src_stride3+4]);\
  582. d= LD32(&src4[i*src_stride4+4]);\
  583. l0= (a&0x03030303UL)\
  584. + (b&0x03030303UL)\
  585. + 0x02020202UL;\
  586. h0= ((a&0xFCFCFCFCUL)>>2)\
  587. + ((b&0xFCFCFCFCUL)>>2);\
  588. l1= (c&0x03030303UL)\
  589. + (d&0x03030303UL);\
  590. h1= ((c&0xFCFCFCFCUL)>>2)\
  591. + ((d&0xFCFCFCFCUL)>>2);\
  592. OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  593. }\
  594. }\
  595. \
  596. static inline void OPNAME ## _pixels4_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  597. OPNAME ## _pixels4_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
  598. }\
  599. \
  600. static inline void OPNAME ## _pixels4_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  601. OPNAME ## _pixels4_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
  602. }\
  603. \
  604. static inline void OPNAME ## _pixels2_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  605. OPNAME ## _pixels2_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\
  606. }\
  607. \
  608. static inline void OPNAME ## _pixels2_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
  609. OPNAME ## _pixels2_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\
  610. }\
  611. \
  612. static inline void OPNAME ## _no_rnd_pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
  613. int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
  614. int i;\
  615. for(i=0; i<h; i++){\
  616. uint32_t a, b, c, d, l0, l1, h0, h1;\
  617. a= LD32(&src1[i*src_stride1]);\
  618. b= LD32(&src2[i*src_stride2]);\
  619. c= LD32(&src3[i*src_stride3]);\
  620. d= LD32(&src4[i*src_stride4]);\
  621. l0= (a&0x03030303UL)\
  622. + (b&0x03030303UL)\
  623. + 0x01010101UL;\
  624. h0= ((a&0xFCFCFCFCUL)>>2)\
  625. + ((b&0xFCFCFCFCUL)>>2);\
  626. l1= (c&0x03030303UL)\
  627. + (d&0x03030303UL);\
  628. h1= ((c&0xFCFCFCFCUL)>>2)\
  629. + ((d&0xFCFCFCFCUL)>>2);\
  630. OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  631. a= LD32(&src1[i*src_stride1+4]);\
  632. b= LD32(&src2[i*src_stride2+4]);\
  633. c= LD32(&src3[i*src_stride3+4]);\
  634. d= LD32(&src4[i*src_stride4+4]);\
  635. l0= (a&0x03030303UL)\
  636. + (b&0x03030303UL)\
  637. + 0x01010101UL;\
  638. h0= ((a&0xFCFCFCFCUL)>>2)\
  639. + ((b&0xFCFCFCFCUL)>>2);\
  640. l1= (c&0x03030303UL)\
  641. + (d&0x03030303UL);\
  642. h1= ((c&0xFCFCFCFCUL)>>2)\
  643. + ((d&0xFCFCFCFCUL)>>2);\
  644. OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  645. }\
  646. }\
  647. static inline void OPNAME ## _pixels16_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
  648. int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
  649. OPNAME ## _pixels8_l4(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
  650. OPNAME ## _pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
  651. }\
  652. static inline void OPNAME ## _no_rnd_pixels16_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\
  653. int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
  654. OPNAME ## _no_rnd_pixels8_l4(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
  655. 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);\
  656. }\
  657. \
  658. static inline void OPNAME ## _pixels2_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  659. {\
  660. int i, a0, b0, a1, b1;\
  661. a0= pixels[0];\
  662. b0= pixels[1] + 2;\
  663. a0 += b0;\
  664. b0 += pixels[2];\
  665. \
  666. pixels+=line_size;\
  667. for(i=0; i<h; i+=2){\
  668. a1= pixels[0];\
  669. b1= pixels[1];\
  670. a1 += b1;\
  671. b1 += pixels[2];\
  672. \
  673. block[0]= (a1+a0)>>2; /* FIXME non put */\
  674. block[1]= (b1+b0)>>2;\
  675. \
  676. pixels+=line_size;\
  677. block +=line_size;\
  678. \
  679. a0= pixels[0];\
  680. b0= pixels[1] + 2;\
  681. a0 += b0;\
  682. b0 += pixels[2];\
  683. \
  684. block[0]= (a1+a0)>>2;\
  685. block[1]= (b1+b0)>>2;\
  686. pixels+=line_size;\
  687. block +=line_size;\
  688. }\
  689. }\
  690. \
  691. static inline void OPNAME ## _pixels4_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  692. {\
  693. int i;\
  694. const uint32_t a= LD32(pixels );\
  695. const uint32_t b= LD32(pixels+1);\
  696. uint32_t l0= (a&0x03030303UL)\
  697. + (b&0x03030303UL)\
  698. + 0x02020202UL;\
  699. uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
  700. + ((b&0xFCFCFCFCUL)>>2);\
  701. uint32_t l1,h1;\
  702. \
  703. pixels+=line_size;\
  704. for(i=0; i<h; i+=2){\
  705. uint32_t a= LD32(pixels );\
  706. uint32_t b= LD32(pixels+1);\
  707. l1= (a&0x03030303UL)\
  708. + (b&0x03030303UL);\
  709. h1= ((a&0xFCFCFCFCUL)>>2)\
  710. + ((b&0xFCFCFCFCUL)>>2);\
  711. OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  712. pixels+=line_size;\
  713. block +=line_size;\
  714. a= LD32(pixels );\
  715. b= LD32(pixels+1);\
  716. l0= (a&0x03030303UL)\
  717. + (b&0x03030303UL)\
  718. + 0x02020202UL;\
  719. h0= ((a&0xFCFCFCFCUL)>>2)\
  720. + ((b&0xFCFCFCFCUL)>>2);\
  721. OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  722. pixels+=line_size;\
  723. block +=line_size;\
  724. }\
  725. }\
  726. \
  727. static inline void OPNAME ## _pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  728. {\
  729. int j;\
  730. for(j=0; j<2; j++){\
  731. int i;\
  732. const uint32_t a= LD32(pixels );\
  733. const uint32_t b= LD32(pixels+1);\
  734. uint32_t l0= (a&0x03030303UL)\
  735. + (b&0x03030303UL)\
  736. + 0x02020202UL;\
  737. uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
  738. + ((b&0xFCFCFCFCUL)>>2);\
  739. uint32_t l1,h1;\
  740. \
  741. pixels+=line_size;\
  742. for(i=0; i<h; i+=2){\
  743. uint32_t a= LD32(pixels );\
  744. uint32_t b= LD32(pixels+1);\
  745. l1= (a&0x03030303UL)\
  746. + (b&0x03030303UL);\
  747. h1= ((a&0xFCFCFCFCUL)>>2)\
  748. + ((b&0xFCFCFCFCUL)>>2);\
  749. OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  750. pixels+=line_size;\
  751. block +=line_size;\
  752. a= LD32(pixels );\
  753. b= LD32(pixels+1);\
  754. l0= (a&0x03030303UL)\
  755. + (b&0x03030303UL)\
  756. + 0x02020202UL;\
  757. h0= ((a&0xFCFCFCFCUL)>>2)\
  758. + ((b&0xFCFCFCFCUL)>>2);\
  759. OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  760. pixels+=line_size;\
  761. block +=line_size;\
  762. }\
  763. pixels+=4-line_size*(h+1);\
  764. block +=4-line_size*h;\
  765. }\
  766. }\
  767. \
  768. static inline void OPNAME ## _no_rnd_pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
  769. {\
  770. int j;\
  771. for(j=0; j<2; j++){\
  772. int i;\
  773. const uint32_t a= LD32(pixels );\
  774. const uint32_t b= LD32(pixels+1);\
  775. uint32_t l0= (a&0x03030303UL)\
  776. + (b&0x03030303UL)\
  777. + 0x01010101UL;\
  778. uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
  779. + ((b&0xFCFCFCFCUL)>>2);\
  780. uint32_t l1,h1;\
  781. \
  782. pixels+=line_size;\
  783. for(i=0; i<h; i+=2){\
  784. uint32_t a= LD32(pixels );\
  785. uint32_t b= LD32(pixels+1);\
  786. l1= (a&0x03030303UL)\
  787. + (b&0x03030303UL);\
  788. h1= ((a&0xFCFCFCFCUL)>>2)\
  789. + ((b&0xFCFCFCFCUL)>>2);\
  790. OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  791. pixels+=line_size;\
  792. block +=line_size;\
  793. a= LD32(pixels );\
  794. b= LD32(pixels+1);\
  795. l0= (a&0x03030303UL)\
  796. + (b&0x03030303UL)\
  797. + 0x01010101UL;\
  798. h0= ((a&0xFCFCFCFCUL)>>2)\
  799. + ((b&0xFCFCFCFCUL)>>2);\
  800. OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
  801. pixels+=line_size;\
  802. block +=line_size;\
  803. }\
  804. pixels+=4-line_size*(h+1);\
  805. block +=4-line_size*h;\
  806. }\
  807. }\
  808. \
  809. CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels8_c , 8)\
  810. CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels8_x2_c , 8)\
  811. CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels8_y2_c , 8)\
  812. CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels8_xy2_c, 8)\
  813. CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_c , OPNAME ## _pixels8_c , 8)\
  814. CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels8_x2_c , 8)\
  815. CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels8_y2_c , 8)\
  816. CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels8_xy2_c, 8)\
  817. #define op_avg(a, b) a = rnd_avg32(a, b)
  818. #endif
  819. #define op_put(a, b) a = b
  820. PIXOP2(avg, op_avg)
  821. PIXOP2(put, op_put)
  822. #undef op_avg
  823. #undef op_put
  824. #define avg2(a,b) ((a+b+1)>>1)
  825. #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
  826. static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder)
  827. {
  828. const int A=(16-x16)*(16-y16);
  829. const int B=( x16)*(16-y16);
  830. const int C=(16-x16)*( y16);
  831. const int D=( x16)*( y16);
  832. int i;
  833. for(i=0; i<h; i++)
  834. {
  835. dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8;
  836. dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8;
  837. dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8;
  838. dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8;
  839. dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8;
  840. dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8;
  841. dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8;
  842. dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8;
  843. dst+= stride;
  844. src+= stride;
  845. }
  846. }
  847. static void gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
  848. int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
  849. {
  850. int y, vx, vy;
  851. const int s= 1<<shift;
  852. width--;
  853. height--;
  854. for(y=0; y<h; y++){
  855. int x;
  856. vx= ox;
  857. vy= oy;
  858. for(x=0; x<8; x++){ //XXX FIXME optimize
  859. int src_x, src_y, frac_x, frac_y, index;
  860. src_x= vx>>16;
  861. src_y= vy>>16;
  862. frac_x= src_x&(s-1);
  863. frac_y= src_y&(s-1);
  864. src_x>>=shift;
  865. src_y>>=shift;
  866. if((unsigned)src_x < width){
  867. if((unsigned)src_y < height){
  868. index= src_x + src_y*stride;
  869. dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
  870. + src[index +1]* frac_x )*(s-frac_y)
  871. + ( src[index+stride ]*(s-frac_x)
  872. + src[index+stride+1]* frac_x )* frac_y
  873. + r)>>(shift*2);
  874. }else{
  875. index= src_x + clip(src_y, 0, height)*stride;
  876. dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
  877. + src[index +1]* frac_x )*s
  878. + r)>>(shift*2);
  879. }
  880. }else{
  881. if((unsigned)src_y < height){
  882. index= clip(src_x, 0, width) + src_y*stride;
  883. dst[y*stride + x]= ( ( src[index ]*(s-frac_y)
  884. + src[index+stride ]* frac_y )*s
  885. + r)>>(shift*2);
  886. }else{
  887. index= clip(src_x, 0, width) + clip(src_y, 0, height)*stride;
  888. dst[y*stride + x]= src[index ];
  889. }
  890. }
  891. vx+= dxx;
  892. vy+= dyx;
  893. }
  894. ox += dxy;
  895. oy += dyy;
  896. }
  897. }
  898. static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  899. switch(width){
  900. case 2: put_pixels2_c (dst, src, stride, height); break;
  901. case 4: put_pixels4_c (dst, src, stride, height); break;
  902. case 8: put_pixels8_c (dst, src, stride, height); break;
  903. case 16:put_pixels16_c(dst, src, stride, height); break;
  904. }
  905. }
  906. static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  907. int i,j;
  908. for (i=0; i < height; i++) {
  909. for (j=0; j < width; j++) {
  910. dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11;
  911. }
  912. src += stride;
  913. dst += stride;
  914. }
  915. }
  916. static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  917. int i,j;
  918. for (i=0; i < height; i++) {
  919. for (j=0; j < width; j++) {
  920. dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11;
  921. }
  922. src += stride;
  923. dst += stride;
  924. }
  925. }
  926. static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  927. int i,j;
  928. for (i=0; i < height; i++) {
  929. for (j=0; j < width; j++) {
  930. dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11;
  931. }
  932. src += stride;
  933. dst += stride;
  934. }
  935. }
  936. static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  937. int i,j;
  938. for (i=0; i < height; i++) {
  939. for (j=0; j < width; j++) {
  940. dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15;
  941. }
  942. src += stride;
  943. dst += stride;
  944. }
  945. }
  946. static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  947. int i,j;
  948. for (i=0; i < height; i++) {
  949. for (j=0; j < width; j++) {
  950. dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
  951. }
  952. src += stride;
  953. dst += stride;
  954. }
  955. }
  956. static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  957. int i,j;
  958. for (i=0; i < height; i++) {
  959. for (j=0; j < width; j++) {
  960. dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11;
  961. }
  962. src += stride;
  963. dst += stride;
  964. }
  965. }
  966. static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  967. int i,j;
  968. for (i=0; i < height; i++) {
  969. for (j=0; j < width; j++) {
  970. dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
  971. }
  972. src += stride;
  973. dst += stride;
  974. }
  975. }
  976. static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  977. int i,j;
  978. for (i=0; i < height; i++) {
  979. for (j=0; j < width; j++) {
  980. dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15;
  981. }
  982. src += stride;
  983. dst += stride;
  984. }
  985. }
  986. static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  987. switch(width){
  988. case 2: avg_pixels2_c (dst, src, stride, height); break;
  989. case 4: avg_pixels4_c (dst, src, stride, height); break;
  990. case 8: avg_pixels8_c (dst, src, stride, height); break;
  991. case 16:avg_pixels16_c(dst, src, stride, height); break;
  992. }
  993. }
  994. static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  995. int i,j;
  996. for (i=0; i < height; i++) {
  997. for (j=0; j < width; j++) {
  998. dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1;
  999. }
  1000. src += stride;
  1001. dst += stride;
  1002. }
  1003. }
  1004. static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  1005. int i,j;
  1006. for (i=0; i < height; i++) {
  1007. for (j=0; j < width; j++) {
  1008. dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1;
  1009. }
  1010. src += stride;
  1011. dst += stride;
  1012. }
  1013. }
  1014. static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  1015. int i,j;
  1016. for (i=0; i < height; i++) {
  1017. for (j=0; j < width; j++) {
  1018. dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1;
  1019. }
  1020. src += stride;
  1021. dst += stride;
  1022. }
  1023. }
  1024. static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  1025. int i,j;
  1026. for (i=0; i < height; i++) {
  1027. for (j=0; j < width; j++) {
  1028. dst[j] = (dst[j] + ((2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
  1029. }
  1030. src += stride;
  1031. dst += stride;
  1032. }
  1033. }
  1034. static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  1035. int i,j;
  1036. for (i=0; i < height; i++) {
  1037. for (j=0; j < width; j++) {
  1038. dst[j] = (dst[j] + ((2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
  1039. }
  1040. src += stride;
  1041. dst += stride;
  1042. }
  1043. }
  1044. static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  1045. int i,j;
  1046. for (i=0; i < height; i++) {
  1047. for (j=0; j < width; j++) {
  1048. dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1;
  1049. }
  1050. src += stride;
  1051. dst += stride;
  1052. }
  1053. }
  1054. static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  1055. int i,j;
  1056. for (i=0; i < height; i++) {
  1057. for (j=0; j < width; j++) {
  1058. dst[j] = (dst[j] + ((2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
  1059. }
  1060. src += stride;
  1061. dst += stride;
  1062. }
  1063. }
  1064. static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  1065. int i,j;
  1066. for (i=0; i < height; i++) {
  1067. for (j=0; j < width; j++) {
  1068. dst[j] = (dst[j] + ((2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
  1069. }
  1070. src += stride;
  1071. dst += stride;
  1072. }
  1073. }
  1074. #if 0
  1075. #define TPEL_WIDTH(width)\
  1076. static void put_tpel_pixels ## width ## _mc00_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1077. void put_tpel_pixels_mc00_c(dst, src, stride, width, height);}\
  1078. static void put_tpel_pixels ## width ## _mc10_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1079. void put_tpel_pixels_mc10_c(dst, src, stride, width, height);}\
  1080. static void put_tpel_pixels ## width ## _mc20_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1081. void put_tpel_pixels_mc20_c(dst, src, stride, width, height);}\
  1082. static void put_tpel_pixels ## width ## _mc01_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1083. void put_tpel_pixels_mc01_c(dst, src, stride, width, height);}\
  1084. static void put_tpel_pixels ## width ## _mc11_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1085. void put_tpel_pixels_mc11_c(dst, src, stride, width, height);}\
  1086. static void put_tpel_pixels ## width ## _mc21_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1087. void put_tpel_pixels_mc21_c(dst, src, stride, width, height);}\
  1088. static void put_tpel_pixels ## width ## _mc02_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1089. void put_tpel_pixels_mc02_c(dst, src, stride, width, height);}\
  1090. static void put_tpel_pixels ## width ## _mc12_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1091. void put_tpel_pixels_mc12_c(dst, src, stride, width, height);}\
  1092. static void put_tpel_pixels ## width ## _mc22_c(uint8_t *dst, const uint8_t *src, int stride, int height){\
  1093. void put_tpel_pixels_mc22_c(dst, src, stride, width, height);}
  1094. #endif
  1095. #define H264_CHROMA_MC(OPNAME, OP)\
  1096. static void OPNAME ## h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
  1097. const int A=(8-x)*(8-y);\
  1098. const int B=( x)*(8-y);\
  1099. const int C=(8-x)*( y);\
  1100. const int D=( x)*( y);\
  1101. int i;\
  1102. \
  1103. assert(x<8 && y<8 && x>=0 && y>=0);\
  1104. \
  1105. for(i=0; i<h; i++)\
  1106. {\
  1107. OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
  1108. OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
  1109. dst+= stride;\
  1110. src+= stride;\
  1111. }\
  1112. }\
  1113. \
  1114. static void OPNAME ## h264_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
  1115. const int A=(8-x)*(8-y);\
  1116. const int B=( x)*(8-y);\
  1117. const int C=(8-x)*( y);\
  1118. const int D=( x)*( y);\
  1119. int i;\
  1120. \
  1121. assert(x<8 && y<8 && x>=0 && y>=0);\
  1122. \
  1123. for(i=0; i<h; i++)\
  1124. {\
  1125. OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
  1126. OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
  1127. OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
  1128. OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
  1129. dst+= stride;\
  1130. src+= stride;\
  1131. }\
  1132. }\
  1133. \
  1134. static void OPNAME ## h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\
  1135. const int A=(8-x)*(8-y);\
  1136. const int B=( x)*(8-y);\
  1137. const int C=(8-x)*( y);\
  1138. const int D=( x)*( y);\
  1139. int i;\
  1140. \
  1141. assert(x<8 && y<8 && x>=0 && y>=0);\
  1142. \
  1143. for(i=0; i<h; i++)\
  1144. {\
  1145. OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
  1146. OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
  1147. OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
  1148. OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
  1149. OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
  1150. OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
  1151. OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
  1152. OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
  1153. dst+= stride;\
  1154. src+= stride;\
  1155. }\
  1156. }
  1157. #define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1)
  1158. #define op_put(a, b) a = (((b) + 32)>>6)
  1159. H264_CHROMA_MC(put_ , op_put)
  1160. H264_CHROMA_MC(avg_ , op_avg)
  1161. #undef op_avg
  1162. #undef op_put
  1163. static inline void copy_block4(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
  1164. {
  1165. int i;
  1166. for(i=0; i<h; i++)
  1167. {
  1168. ST32(dst , LD32(src ));
  1169. dst+=dstStride;
  1170. src+=srcStride;
  1171. }
  1172. }
  1173. static inline void copy_block8(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
  1174. {
  1175. int i;
  1176. for(i=0; i<h; i++)
  1177. {
  1178. ST32(dst , LD32(src ));
  1179. ST32(dst+4 , LD32(src+4 ));
  1180. dst+=dstStride;
  1181. src+=srcStride;
  1182. }
  1183. }
  1184. static inline void copy_block16(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
  1185. {
  1186. int i;
  1187. for(i=0; i<h; i++)
  1188. {
  1189. ST32(dst , LD32(src ));
  1190. ST32(dst+4 , LD32(src+4 ));
  1191. ST32(dst+8 , LD32(src+8 ));
  1192. ST32(dst+12, LD32(src+12));
  1193. dst+=dstStride;
  1194. src+=srcStride;
  1195. }
  1196. }
  1197. static inline void copy_block17(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
  1198. {
  1199. int i;
  1200. for(i=0; i<h; i++)
  1201. {
  1202. ST32(dst , LD32(src ));
  1203. ST32(dst+4 , LD32(src+4 ));
  1204. ST32(dst+8 , LD32(src+8 ));
  1205. ST32(dst+12, LD32(src+12));
  1206. dst[16]= src[16];
  1207. dst+=dstStride;
  1208. src+=srcStride;
  1209. }
  1210. }
  1211. static inline void copy_block9(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h)
  1212. {
  1213. int i;
  1214. for(i=0; i<h; i++)
  1215. {
  1216. ST32(dst , LD32(src ));
  1217. ST32(dst+4 , LD32(src+4 ));
  1218. dst[8]= src[8];
  1219. dst+=dstStride;
  1220. src+=srcStride;
  1221. }
  1222. }
  1223. #define QPEL_MC(r, OPNAME, RND, OP) \
  1224. static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
  1225. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1226. int i;\
  1227. for(i=0; i<h; i++)\
  1228. {\
  1229. OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\
  1230. OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\
  1231. OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\
  1232. OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\
  1233. OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\
  1234. OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\
  1235. OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\
  1236. OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\
  1237. dst+=dstStride;\
  1238. src+=srcStride;\
  1239. }\
  1240. }\
  1241. \
  1242. static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  1243. const int w=8;\
  1244. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1245. int i;\
  1246. for(i=0; i<w; i++)\
  1247. {\
  1248. const int src0= src[0*srcStride];\
  1249. const int src1= src[1*srcStride];\
  1250. const int src2= src[2*srcStride];\
  1251. const int src3= src[3*srcStride];\
  1252. const int src4= src[4*srcStride];\
  1253. const int src5= src[5*srcStride];\
  1254. const int src6= src[6*srcStride];\
  1255. const int src7= src[7*srcStride];\
  1256. const int src8= src[8*srcStride];\
  1257. OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\
  1258. OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\
  1259. OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\
  1260. OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\
  1261. OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\
  1262. OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\
  1263. OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\
  1264. OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\
  1265. dst++;\
  1266. src++;\
  1267. }\
  1268. }\
  1269. \
  1270. static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
  1271. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1272. int i;\
  1273. \
  1274. for(i=0; i<h; i++)\
  1275. {\
  1276. OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\
  1277. OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\
  1278. OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\
  1279. OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\
  1280. OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\
  1281. OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\
  1282. OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\
  1283. OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\
  1284. OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\
  1285. OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\
  1286. OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\
  1287. OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\
  1288. OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\
  1289. OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\
  1290. OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\
  1291. OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\
  1292. dst+=dstStride;\
  1293. src+=srcStride;\
  1294. }\
  1295. }\
  1296. \
  1297. static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  1298. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1299. int i;\
  1300. const int w=16;\
  1301. for(i=0; i<w; i++)\
  1302. {\
  1303. const int src0= src[0*srcStride];\
  1304. const int src1= src[1*srcStride];\
  1305. const int src2= src[2*srcStride];\
  1306. const int src3= src[3*srcStride];\
  1307. const int src4= src[4*srcStride];\
  1308. const int src5= src[5*srcStride];\
  1309. const int src6= src[6*srcStride];\
  1310. const int src7= src[7*srcStride];\
  1311. const int src8= src[8*srcStride];\
  1312. const int src9= src[9*srcStride];\
  1313. const int src10= src[10*srcStride];\
  1314. const int src11= src[11*srcStride];\
  1315. const int src12= src[12*srcStride];\
  1316. const int src13= src[13*srcStride];\
  1317. const int src14= src[14*srcStride];\
  1318. const int src15= src[15*srcStride];\
  1319. const int src16= src[16*srcStride];\
  1320. OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\
  1321. OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\
  1322. OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\
  1323. OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\
  1324. OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\
  1325. OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\
  1326. OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\
  1327. OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\
  1328. OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\
  1329. OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\
  1330. OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\
  1331. OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\
  1332. OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\
  1333. OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\
  1334. OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\
  1335. OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\
  1336. dst++;\
  1337. src++;\
  1338. }\
  1339. }\
  1340. \
  1341. static void OPNAME ## qpel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
  1342. OPNAME ## pixels8_c(dst, src, stride, 8);\
  1343. }\
  1344. \
  1345. static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
  1346. uint8_t half[64];\
  1347. put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
  1348. OPNAME ## pixels8_l2(dst, src, half, stride, stride, 8, 8);\
  1349. }\
  1350. \
  1351. static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
  1352. OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
  1353. }\
  1354. \
  1355. static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
  1356. uint8_t half[64];\
  1357. put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
  1358. OPNAME ## pixels8_l2(dst, src+1, half, stride, stride, 8, 8);\
  1359. }\
  1360. \
  1361. static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
  1362. uint8_t full[16*9];\
  1363. uint8_t half[64];\
  1364. copy_block9(full, src, 16, stride, 9);\
  1365. put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
  1366. OPNAME ## pixels8_l2(dst, full, half, stride, 16, 8, 8);\
  1367. }\
  1368. \
  1369. static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
  1370. uint8_t full[16*9];\
  1371. copy_block9(full, src, 16, stride, 9);\
  1372. OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\
  1373. }\
  1374. \
  1375. static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
  1376. uint8_t full[16*9];\
  1377. uint8_t half[64];\
  1378. copy_block9(full, src, 16, stride, 9);\
  1379. put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
  1380. OPNAME ## pixels8_l2(dst, full+16, half, stride, 16, 8, 8);\
  1381. }\
  1382. void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1383. uint8_t full[16*9];\
  1384. uint8_t halfH[72];\
  1385. uint8_t halfV[64];\
  1386. uint8_t halfHV[64];\
  1387. copy_block9(full, src, 16, stride, 9);\
  1388. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1389. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
  1390. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1391. OPNAME ## pixels8_l4(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
  1392. }\
  1393. static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
  1394. uint8_t full[16*9];\
  1395. uint8_t halfH[72];\
  1396. uint8_t halfHV[64];\
  1397. copy_block9(full, src, 16, stride, 9);\
  1398. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1399. put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
  1400. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1401. OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
  1402. }\
  1403. void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1404. uint8_t full[16*9];\
  1405. uint8_t halfH[72];\
  1406. uint8_t halfV[64];\
  1407. uint8_t halfHV[64];\
  1408. copy_block9(full, src, 16, stride, 9);\
  1409. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1410. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
  1411. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1412. OPNAME ## pixels8_l4(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
  1413. }\
  1414. static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
  1415. uint8_t full[16*9];\
  1416. uint8_t halfH[72];\
  1417. uint8_t halfHV[64];\
  1418. copy_block9(full, src, 16, stride, 9);\
  1419. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1420. put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
  1421. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1422. OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
  1423. }\
  1424. void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1425. uint8_t full[16*9];\
  1426. uint8_t halfH[72];\
  1427. uint8_t halfV[64];\
  1428. uint8_t halfHV[64];\
  1429. copy_block9(full, src, 16, stride, 9);\
  1430. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1431. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
  1432. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1433. OPNAME ## pixels8_l4(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
  1434. }\
  1435. static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
  1436. uint8_t full[16*9];\
  1437. uint8_t halfH[72];\
  1438. uint8_t halfHV[64];\
  1439. copy_block9(full, src, 16, stride, 9);\
  1440. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1441. put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
  1442. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1443. OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
  1444. }\
  1445. void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1446. uint8_t full[16*9];\
  1447. uint8_t halfH[72];\
  1448. uint8_t halfV[64];\
  1449. uint8_t halfHV[64];\
  1450. copy_block9(full, src, 16, stride, 9);\
  1451. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\
  1452. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
  1453. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1454. OPNAME ## pixels8_l4(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
  1455. }\
  1456. static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
  1457. uint8_t full[16*9];\
  1458. uint8_t halfH[72];\
  1459. uint8_t halfHV[64];\
  1460. copy_block9(full, src, 16, stride, 9);\
  1461. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1462. put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
  1463. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1464. OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
  1465. }\
  1466. static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
  1467. uint8_t halfH[72];\
  1468. uint8_t halfHV[64];\
  1469. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
  1470. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1471. OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\
  1472. }\
  1473. static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
  1474. uint8_t halfH[72];\
  1475. uint8_t halfHV[64];\
  1476. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
  1477. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1478. OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\
  1479. }\
  1480. void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1481. uint8_t full[16*9];\
  1482. uint8_t halfH[72];\
  1483. uint8_t halfV[64];\
  1484. uint8_t halfHV[64];\
  1485. copy_block9(full, src, 16, stride, 9);\
  1486. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1487. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
  1488. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1489. OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\
  1490. }\
  1491. static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
  1492. uint8_t full[16*9];\
  1493. uint8_t halfH[72];\
  1494. copy_block9(full, src, 16, stride, 9);\
  1495. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1496. put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\
  1497. OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
  1498. }\
  1499. void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1500. uint8_t full[16*9];\
  1501. uint8_t halfH[72];\
  1502. uint8_t halfV[64];\
  1503. uint8_t halfHV[64];\
  1504. copy_block9(full, src, 16, stride, 9);\
  1505. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1506. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
  1507. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1508. OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\
  1509. }\
  1510. static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
  1511. uint8_t full[16*9];\
  1512. uint8_t halfH[72];\
  1513. copy_block9(full, src, 16, stride, 9);\
  1514. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1515. put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\
  1516. OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
  1517. }\
  1518. static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
  1519. uint8_t halfH[72];\
  1520. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
  1521. OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
  1522. }\
  1523. static void OPNAME ## qpel16_mc00_c (uint8_t *dst, uint8_t *src, int stride){\
  1524. OPNAME ## pixels16_c(dst, src, stride, 16);\
  1525. }\
  1526. \
  1527. static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\
  1528. uint8_t half[256];\
  1529. put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
  1530. OPNAME ## pixels16_l2(dst, src, half, stride, stride, 16, 16);\
  1531. }\
  1532. \
  1533. static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\
  1534. OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
  1535. }\
  1536. \
  1537. static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int stride){\
  1538. uint8_t half[256];\
  1539. put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
  1540. OPNAME ## pixels16_l2(dst, src+1, half, stride, stride, 16, 16);\
  1541. }\
  1542. \
  1543. static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\
  1544. uint8_t full[24*17];\
  1545. uint8_t half[256];\
  1546. copy_block17(full, src, 24, stride, 17);\
  1547. put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
  1548. OPNAME ## pixels16_l2(dst, full, half, stride, 24, 16, 16);\
  1549. }\
  1550. \
  1551. static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, int stride){\
  1552. uint8_t full[24*17];\
  1553. copy_block17(full, src, 24, stride, 17);\
  1554. OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\
  1555. }\
  1556. \
  1557. static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, int stride){\
  1558. uint8_t full[24*17];\
  1559. uint8_t half[256];\
  1560. copy_block17(full, src, 24, stride, 17);\
  1561. put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
  1562. OPNAME ## pixels16_l2(dst, full+24, half, stride, 24, 16, 16);\
  1563. }\
  1564. void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1565. uint8_t full[24*17];\
  1566. uint8_t halfH[272];\
  1567. uint8_t halfV[256];\
  1568. uint8_t halfHV[256];\
  1569. copy_block17(full, src, 24, stride, 17);\
  1570. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1571. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
  1572. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1573. OPNAME ## pixels16_l4(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
  1574. }\
  1575. static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\
  1576. uint8_t full[24*17];\
  1577. uint8_t halfH[272];\
  1578. uint8_t halfHV[256];\
  1579. copy_block17(full, src, 24, stride, 17);\
  1580. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1581. put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
  1582. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1583. OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
  1584. }\
  1585. void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1586. uint8_t full[24*17];\
  1587. uint8_t halfH[272];\
  1588. uint8_t halfV[256];\
  1589. uint8_t halfHV[256];\
  1590. copy_block17(full, src, 24, stride, 17);\
  1591. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1592. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
  1593. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1594. OPNAME ## pixels16_l4(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
  1595. }\
  1596. static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\
  1597. uint8_t full[24*17];\
  1598. uint8_t halfH[272];\
  1599. uint8_t halfHV[256];\
  1600. copy_block17(full, src, 24, stride, 17);\
  1601. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1602. put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
  1603. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1604. OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
  1605. }\
  1606. void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1607. uint8_t full[24*17];\
  1608. uint8_t halfH[272];\
  1609. uint8_t halfV[256];\
  1610. uint8_t halfHV[256];\
  1611. copy_block17(full, src, 24, stride, 17);\
  1612. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1613. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
  1614. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1615. OPNAME ## pixels16_l4(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
  1616. }\
  1617. static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\
  1618. uint8_t full[24*17];\
  1619. uint8_t halfH[272];\
  1620. uint8_t halfHV[256];\
  1621. copy_block17(full, src, 24, stride, 17);\
  1622. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1623. put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
  1624. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1625. OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
  1626. }\
  1627. void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1628. uint8_t full[24*17];\
  1629. uint8_t halfH[272];\
  1630. uint8_t halfV[256];\
  1631. uint8_t halfHV[256];\
  1632. copy_block17(full, src, 24, stride, 17);\
  1633. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\
  1634. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
  1635. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1636. OPNAME ## pixels16_l4(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
  1637. }\
  1638. static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\
  1639. uint8_t full[24*17];\
  1640. uint8_t halfH[272];\
  1641. uint8_t halfHV[256];\
  1642. copy_block17(full, src, 24, stride, 17);\
  1643. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1644. put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
  1645. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1646. OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
  1647. }\
  1648. static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, int stride){\
  1649. uint8_t halfH[272];\
  1650. uint8_t halfHV[256];\
  1651. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
  1652. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1653. OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\
  1654. }\
  1655. static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, int stride){\
  1656. uint8_t halfH[272];\
  1657. uint8_t halfHV[256];\
  1658. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
  1659. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1660. OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\
  1661. }\
  1662. void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1663. uint8_t full[24*17];\
  1664. uint8_t halfH[272];\
  1665. uint8_t halfV[256];\
  1666. uint8_t halfHV[256];\
  1667. copy_block17(full, src, 24, stride, 17);\
  1668. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1669. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
  1670. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1671. OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\
  1672. }\
  1673. static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, int stride){\
  1674. uint8_t full[24*17];\
  1675. uint8_t halfH[272];\
  1676. copy_block17(full, src, 24, stride, 17);\
  1677. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1678. put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\
  1679. OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
  1680. }\
  1681. void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\
  1682. uint8_t full[24*17];\
  1683. uint8_t halfH[272];\
  1684. uint8_t halfV[256];\
  1685. uint8_t halfHV[256];\
  1686. copy_block17(full, src, 24, stride, 17);\
  1687. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1688. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
  1689. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1690. OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\
  1691. }\
  1692. static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, int stride){\
  1693. uint8_t full[24*17];\
  1694. uint8_t halfH[272];\
  1695. copy_block17(full, src, 24, stride, 17);\
  1696. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1697. put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\
  1698. OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
  1699. }\
  1700. static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, int stride){\
  1701. uint8_t halfH[272];\
  1702. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
  1703. OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
  1704. }
  1705. #define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
  1706. #define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1)
  1707. #define op_put(a, b) a = cm[((b) + 16)>>5]
  1708. #define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5]
  1709. QPEL_MC(0, put_ , _ , op_put)
  1710. QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
  1711. QPEL_MC(0, avg_ , _ , op_avg)
  1712. //QPEL_MC(1, avg_no_rnd , _ , op_avg)
  1713. #undef op_avg
  1714. #undef op_avg_no_rnd
  1715. #undef op_put
  1716. #undef op_put_no_rnd
  1717. #if 1
  1718. #define H264_LOWPASS(OPNAME, OP, OP2) \
  1719. static void OPNAME ## h264_qpel4_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  1720. const int h=4;\
  1721. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1722. int i;\
  1723. for(i=0; i<h; i++)\
  1724. {\
  1725. OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\
  1726. OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\
  1727. OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\
  1728. OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\
  1729. dst+=dstStride;\
  1730. src+=srcStride;\
  1731. }\
  1732. }\
  1733. \
  1734. static void OPNAME ## h264_qpel4_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  1735. const int w=4;\
  1736. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1737. int i;\
  1738. for(i=0; i<w; i++)\
  1739. {\
  1740. const int srcB= src[-2*srcStride];\
  1741. const int srcA= src[-1*srcStride];\
  1742. const int src0= src[0 *srcStride];\
  1743. const int src1= src[1 *srcStride];\
  1744. const int src2= src[2 *srcStride];\
  1745. const int src3= src[3 *srcStride];\
  1746. const int src4= src[4 *srcStride];\
  1747. const int src5= src[5 *srcStride];\
  1748. const int src6= src[6 *srcStride];\
  1749. OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
  1750. OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
  1751. OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
  1752. OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
  1753. dst++;\
  1754. src++;\
  1755. }\
  1756. }\
  1757. \
  1758. static void OPNAME ## h264_qpel4_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  1759. const int h=4;\
  1760. const int w=4;\
  1761. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1762. int i;\
  1763. src -= 2*srcStride;\
  1764. for(i=0; i<h+5; i++)\
  1765. {\
  1766. tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);\
  1767. tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);\
  1768. tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]);\
  1769. tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]);\
  1770. tmp+=tmpStride;\
  1771. src+=srcStride;\
  1772. }\
  1773. tmp -= tmpStride*(h+5-2);\
  1774. for(i=0; i<w; i++)\
  1775. {\
  1776. const int tmpB= tmp[-2*tmpStride];\
  1777. const int tmpA= tmp[-1*tmpStride];\
  1778. const int tmp0= tmp[0 *tmpStride];\
  1779. const int tmp1= tmp[1 *tmpStride];\
  1780. const int tmp2= tmp[2 *tmpStride];\
  1781. const int tmp3= tmp[3 *tmpStride];\
  1782. const int tmp4= tmp[4 *tmpStride];\
  1783. const int tmp5= tmp[5 *tmpStride];\
  1784. const int tmp6= tmp[6 *tmpStride];\
  1785. OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
  1786. OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
  1787. OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
  1788. OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
  1789. dst++;\
  1790. tmp++;\
  1791. }\
  1792. }\
  1793. \
  1794. static void OPNAME ## h264_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  1795. const int h=8;\
  1796. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1797. int i;\
  1798. for(i=0; i<h; i++)\
  1799. {\
  1800. OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\
  1801. OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\
  1802. OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\
  1803. OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\
  1804. OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\
  1805. OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\
  1806. OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\
  1807. OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\
  1808. dst+=dstStride;\
  1809. src+=srcStride;\
  1810. }\
  1811. }\
  1812. \
  1813. static void OPNAME ## h264_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  1814. const int w=8;\
  1815. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1816. int i;\
  1817. for(i=0; i<w; i++)\
  1818. {\
  1819. const int srcB= src[-2*srcStride];\
  1820. const int srcA= src[-1*srcStride];\
  1821. const int src0= src[0 *srcStride];\
  1822. const int src1= src[1 *srcStride];\
  1823. const int src2= src[2 *srcStride];\
  1824. const int src3= src[3 *srcStride];\
  1825. const int src4= src[4 *srcStride];\
  1826. const int src5= src[5 *srcStride];\
  1827. const int src6= src[6 *srcStride];\
  1828. const int src7= src[7 *srcStride];\
  1829. const int src8= src[8 *srcStride];\
  1830. const int src9= src[9 *srcStride];\
  1831. const int src10=src[10*srcStride];\
  1832. OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\
  1833. OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\
  1834. OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\
  1835. OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\
  1836. OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\
  1837. OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\
  1838. OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\
  1839. OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\
  1840. dst++;\
  1841. src++;\
  1842. }\
  1843. }\
  1844. \
  1845. static void OPNAME ## h264_qpel8_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  1846. const int h=8;\
  1847. const int w=8;\
  1848. uint8_t *cm = cropTbl + MAX_NEG_CROP;\
  1849. int i;\
  1850. src -= 2*srcStride;\
  1851. for(i=0; i<h+5; i++)\
  1852. {\
  1853. tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]);\
  1854. tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]);\
  1855. tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]);\
  1856. tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]);\
  1857. tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]);\
  1858. tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]);\
  1859. tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]);\
  1860. tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]);\
  1861. tmp+=tmpStride;\
  1862. src+=srcStride;\
  1863. }\
  1864. tmp -= tmpStride*(h+5-2);\
  1865. for(i=0; i<w; i++)\
  1866. {\
  1867. const int tmpB= tmp[-2*tmpStride];\
  1868. const int tmpA= tmp[-1*tmpStride];\
  1869. const int tmp0= tmp[0 *tmpStride];\
  1870. const int tmp1= tmp[1 *tmpStride];\
  1871. const int tmp2= tmp[2 *tmpStride];\
  1872. const int tmp3= tmp[3 *tmpStride];\
  1873. const int tmp4= tmp[4 *tmpStride];\
  1874. const int tmp5= tmp[5 *tmpStride];\
  1875. const int tmp6= tmp[6 *tmpStride];\
  1876. const int tmp7= tmp[7 *tmpStride];\
  1877. const int tmp8= tmp[8 *tmpStride];\
  1878. const int tmp9= tmp[9 *tmpStride];\
  1879. const int tmp10=tmp[10*tmpStride];\
  1880. OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\
  1881. OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\
  1882. OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\
  1883. OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\
  1884. OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\
  1885. OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\
  1886. OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\
  1887. OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\
  1888. dst++;\
  1889. tmp++;\
  1890. }\
  1891. }\
  1892. \
  1893. static void OPNAME ## h264_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  1894. OPNAME ## h264_qpel8_v_lowpass(dst , src , dstStride, srcStride);\
  1895. OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\
  1896. src += 8*srcStride;\
  1897. dst += 8*dstStride;\
  1898. OPNAME ## h264_qpel8_v_lowpass(dst , src , dstStride, srcStride);\
  1899. OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\
  1900. }\
  1901. \
  1902. static void OPNAME ## h264_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  1903. OPNAME ## h264_qpel8_h_lowpass(dst , src , dstStride, srcStride);\
  1904. OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\
  1905. src += 8*srcStride;\
  1906. dst += 8*dstStride;\
  1907. OPNAME ## h264_qpel8_h_lowpass(dst , src , dstStride, srcStride);\
  1908. OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\
  1909. }\
  1910. \
  1911. static void OPNAME ## h264_qpel16_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
  1912. OPNAME ## h264_qpel8_hv_lowpass(dst , tmp , src , dstStride, tmpStride, srcStride);\
  1913. OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\
  1914. src += 8*srcStride;\
  1915. tmp += 8*tmpStride;\
  1916. dst += 8*dstStride;\
  1917. OPNAME ## h264_qpel8_hv_lowpass(dst , tmp , src , dstStride, tmpStride, srcStride);\
  1918. OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\
  1919. }\
  1920. #define H264_MC(OPNAME, SIZE) \
  1921. static void OPNAME ## h264_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\
  1922. OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
  1923. }\
  1924. \
  1925. static void OPNAME ## h264_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
  1926. uint8_t half[SIZE*SIZE];\
  1927. put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\
  1928. OPNAME ## pixels ## SIZE ## _l2(dst, src, half, stride, stride, SIZE, SIZE);\
  1929. }\
  1930. \
  1931. static void OPNAME ## h264_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
  1932. OPNAME ## h264_qpel ## SIZE ## _h_lowpass(dst, src, stride, stride);\
  1933. }\
  1934. \
  1935. static void OPNAME ## h264_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
  1936. uint8_t half[SIZE*SIZE];\
  1937. put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\
  1938. OPNAME ## pixels ## SIZE ## _l2(dst, src+1, half, stride, stride, SIZE, SIZE);\
  1939. }\
  1940. \
  1941. static void OPNAME ## h264_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
  1942. uint8_t full[SIZE*(SIZE+5)];\
  1943. uint8_t * const full_mid= full + SIZE*2;\
  1944. uint8_t half[SIZE*SIZE];\
  1945. copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
  1946. put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\
  1947. OPNAME ## pixels ## SIZE ## _l2(dst, full_mid, half, stride, SIZE, SIZE, SIZE);\
  1948. }\
  1949. \
  1950. static void OPNAME ## h264_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
  1951. uint8_t full[SIZE*(SIZE+5)];\
  1952. uint8_t * const full_mid= full + SIZE*2;\
  1953. copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
  1954. OPNAME ## h264_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE);\
  1955. }\
  1956. \
  1957. static void OPNAME ## h264_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
  1958. uint8_t full[SIZE*(SIZE+5)];\
  1959. uint8_t * const full_mid= full + SIZE*2;\
  1960. uint8_t half[SIZE*SIZE];\
  1961. copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
  1962. put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\
  1963. OPNAME ## pixels ## SIZE ## _l2(dst, full_mid+SIZE, half, stride, SIZE, SIZE, SIZE);\
  1964. }\
  1965. \
  1966. static void OPNAME ## h264_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
  1967. uint8_t full[SIZE*(SIZE+5)];\
  1968. uint8_t * const full_mid= full + SIZE*2;\
  1969. uint8_t halfH[SIZE*SIZE];\
  1970. uint8_t halfV[SIZE*SIZE];\
  1971. put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
  1972. copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
  1973. put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
  1974. OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
  1975. }\
  1976. \
  1977. static void OPNAME ## h264_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
  1978. uint8_t full[SIZE*(SIZE+5)];\
  1979. uint8_t * const full_mid= full + SIZE*2;\
  1980. uint8_t halfH[SIZE*SIZE];\
  1981. uint8_t halfV[SIZE*SIZE];\
  1982. put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
  1983. copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\
  1984. put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
  1985. OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
  1986. }\
  1987. \
  1988. static void OPNAME ## h264_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
  1989. uint8_t full[SIZE*(SIZE+5)];\
  1990. uint8_t * const full_mid= full + SIZE*2;\
  1991. uint8_t halfH[SIZE*SIZE];\
  1992. uint8_t halfV[SIZE*SIZE];\
  1993. put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
  1994. copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
  1995. put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
  1996. OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
  1997. }\
  1998. \
  1999. static void OPNAME ## h264_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
  2000. uint8_t full[SIZE*(SIZE+5)];\
  2001. uint8_t * const full_mid= full + SIZE*2;\
  2002. uint8_t halfH[SIZE*SIZE];\
  2003. uint8_t halfV[SIZE*SIZE];\
  2004. put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
  2005. copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\
  2006. put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
  2007. OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\
  2008. }\
  2009. \
  2010. static void OPNAME ## h264_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
  2011. int16_t tmp[SIZE*(SIZE+5)];\
  2012. OPNAME ## h264_qpel ## SIZE ## _hv_lowpass(dst, tmp, src, stride, SIZE, stride);\
  2013. }\
  2014. \
  2015. static void OPNAME ## h264_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
  2016. int16_t tmp[SIZE*(SIZE+5)];\
  2017. uint8_t halfH[SIZE*SIZE];\
  2018. uint8_t halfHV[SIZE*SIZE];\
  2019. put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\
  2020. put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
  2021. OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
  2022. }\
  2023. \
  2024. static void OPNAME ## h264_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
  2025. int16_t tmp[SIZE*(SIZE+5)];\
  2026. uint8_t halfH[SIZE*SIZE];\
  2027. uint8_t halfHV[SIZE*SIZE];\
  2028. put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\
  2029. put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
  2030. OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\
  2031. }\
  2032. \
  2033. static void OPNAME ## h264_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
  2034. uint8_t full[SIZE*(SIZE+5)];\
  2035. uint8_t * const full_mid= full + SIZE*2;\
  2036. int16_t tmp[SIZE*(SIZE+5)];\
  2037. uint8_t halfV[SIZE*SIZE];\
  2038. uint8_t halfHV[SIZE*SIZE];\
  2039. copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\
  2040. put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
  2041. put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
  2042. OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
  2043. }\
  2044. \
  2045. static void OPNAME ## h264_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
  2046. uint8_t full[SIZE*(SIZE+5)];\
  2047. uint8_t * const full_mid= full + SIZE*2;\
  2048. int16_t tmp[SIZE*(SIZE+5)];\
  2049. uint8_t halfV[SIZE*SIZE];\
  2050. uint8_t halfHV[SIZE*SIZE];\
  2051. copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\
  2052. put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\
  2053. put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\
  2054. OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\
  2055. }\
  2056. #define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
  2057. //#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7)
  2058. #define op_put(a, b) a = cm[((b) + 16)>>5]
  2059. #define op2_avg(a, b) a = (((a)+cm[((b) + 512)>>10]+1)>>1)
  2060. #define op2_put(a, b) a = cm[((b) + 512)>>10]
  2061. H264_LOWPASS(put_ , op_put, op2_put)
  2062. H264_LOWPASS(avg_ , op_avg, op2_avg)
  2063. H264_MC(put_, 4)
  2064. H264_MC(put_, 8)
  2065. H264_MC(put_, 16)
  2066. H264_MC(avg_, 4)
  2067. H264_MC(avg_, 8)
  2068. H264_MC(avg_, 16)
  2069. #undef op_avg
  2070. #undef op_put
  2071. #undef op2_avg
  2072. #undef op2_put
  2073. #endif
  2074. static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
  2075. uint8_t *cm = cropTbl + MAX_NEG_CROP;
  2076. int i;
  2077. for(i=0; i<h; i++){
  2078. dst[0]= cm[(9*(src[0] + src[1]) - (src[-1] + src[2]) + 8)>>4];
  2079. dst[1]= cm[(9*(src[1] + src[2]) - (src[ 0] + src[3]) + 8)>>4];
  2080. dst[2]= cm[(9*(src[2] + src[3]) - (src[ 1] + src[4]) + 8)>>4];
  2081. dst[3]= cm[(9*(src[3] + src[4]) - (src[ 2] + src[5]) + 8)>>4];
  2082. dst[4]= cm[(9*(src[4] + src[5]) - (src[ 3] + src[6]) + 8)>>4];
  2083. dst[5]= cm[(9*(src[5] + src[6]) - (src[ 4] + src[7]) + 8)>>4];
  2084. dst[6]= cm[(9*(src[6] + src[7]) - (src[ 5] + src[8]) + 8)>>4];
  2085. dst[7]= cm[(9*(src[7] + src[8]) - (src[ 6] + src[9]) + 8)>>4];
  2086. dst+=dstStride;
  2087. src+=srcStride;
  2088. }
  2089. }
  2090. static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
  2091. uint8_t *cm = cropTbl + MAX_NEG_CROP;
  2092. int i;
  2093. for(i=0; i<w; i++){
  2094. const int src_1= src[ -srcStride];
  2095. const int src0 = src[0 ];
  2096. const int src1 = src[ srcStride];
  2097. const int src2 = src[2*srcStride];
  2098. const int src3 = src[3*srcStride];
  2099. const int src4 = src[4*srcStride];
  2100. const int src5 = src[5*srcStride];
  2101. const int src6 = src[6*srcStride];
  2102. const int src7 = src[7*srcStride];
  2103. const int src8 = src[8*srcStride];
  2104. const int src9 = src[9*srcStride];
  2105. dst[0*dstStride]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4];
  2106. dst[1*dstStride]= cm[(9*(src1 + src2) - (src0 + src3) + 8)>>4];
  2107. dst[2*dstStride]= cm[(9*(src2 + src3) - (src1 + src4) + 8)>>4];
  2108. dst[3*dstStride]= cm[(9*(src3 + src4) - (src2 + src5) + 8)>>4];
  2109. dst[4*dstStride]= cm[(9*(src4 + src5) - (src3 + src6) + 8)>>4];
  2110. dst[5*dstStride]= cm[(9*(src5 + src6) - (src4 + src7) + 8)>>4];
  2111. dst[6*dstStride]= cm[(9*(src6 + src7) - (src5 + src8) + 8)>>4];
  2112. dst[7*dstStride]= cm[(9*(src7 + src8) - (src6 + src9) + 8)>>4];
  2113. src++;
  2114. dst++;
  2115. }
  2116. }
  2117. static void put_mspel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){
  2118. put_pixels8_c(dst, src, stride, 8);
  2119. }
  2120. static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){
  2121. uint8_t half[64];
  2122. wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
  2123. put_pixels8_l2(dst, src, half, stride, stride, 8, 8);
  2124. }
  2125. static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){
  2126. wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
  2127. }
  2128. static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){
  2129. uint8_t half[64];
  2130. wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
  2131. put_pixels8_l2(dst, src+1, half, stride, stride, 8, 8);
  2132. }
  2133. static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){
  2134. wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
  2135. }
  2136. static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){
  2137. uint8_t halfH[88];
  2138. uint8_t halfV[64];
  2139. uint8_t halfHV[64];
  2140. wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
  2141. wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
  2142. wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
  2143. put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);
  2144. }
  2145. static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){
  2146. uint8_t halfH[88];
  2147. uint8_t halfV[64];
  2148. uint8_t halfHV[64];
  2149. wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
  2150. wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8);
  2151. wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
  2152. put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);
  2153. }
  2154. static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){
  2155. uint8_t halfH[88];
  2156. wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
  2157. wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
  2158. }
  2159. static inline int pix_abs16x16_c(uint8_t *pix1, uint8_t *pix2, int line_size)
  2160. {
  2161. int s, i;
  2162. s = 0;
  2163. for(i=0;i<16;i++) {
  2164. s += abs(pix1[0] - pix2[0]);
  2165. s += abs(pix1[1] - pix2[1]);
  2166. s += abs(pix1[2] - pix2[2]);
  2167. s += abs(pix1[3] - pix2[3]);
  2168. s += abs(pix1[4] - pix2[4]);
  2169. s += abs(pix1[5] - pix2[5]);
  2170. s += abs(pix1[6] - pix2[6]);
  2171. s += abs(pix1[7] - pix2[7]);
  2172. s += abs(pix1[8] - pix2[8]);
  2173. s += abs(pix1[9] - pix2[9]);
  2174. s += abs(pix1[10] - pix2[10]);
  2175. s += abs(pix1[11] - pix2[11]);
  2176. s += abs(pix1[12] - pix2[12]);
  2177. s += abs(pix1[13] - pix2[13]);
  2178. s += abs(pix1[14] - pix2[14]);
  2179. s += abs(pix1[15] - pix2[15]);
  2180. pix1 += line_size;
  2181. pix2 += line_size;
  2182. }
  2183. return s;
  2184. }
  2185. static int pix_abs16x16_x2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
  2186. {
  2187. int s, i;
  2188. s = 0;
  2189. for(i=0;i<16;i++) {
  2190. s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
  2191. s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
  2192. s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
  2193. s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
  2194. s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
  2195. s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
  2196. s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
  2197. s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
  2198. s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
  2199. s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
  2200. s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
  2201. s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
  2202. s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
  2203. s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
  2204. s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
  2205. s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
  2206. pix1 += line_size;
  2207. pix2 += line_size;
  2208. }
  2209. return s;
  2210. }
  2211. static int pix_abs16x16_y2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
  2212. {
  2213. int s, i;
  2214. uint8_t *pix3 = pix2 + line_size;
  2215. s = 0;
  2216. for(i=0;i<16;i++) {
  2217. s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
  2218. s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
  2219. s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
  2220. s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
  2221. s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
  2222. s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
  2223. s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
  2224. s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
  2225. s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
  2226. s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
  2227. s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
  2228. s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
  2229. s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
  2230. s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
  2231. s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
  2232. s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
  2233. pix1 += line_size;
  2234. pix2 += line_size;
  2235. pix3 += line_size;
  2236. }
  2237. return s;
  2238. }
  2239. static int pix_abs16x16_xy2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
  2240. {
  2241. int s, i;
  2242. uint8_t *pix3 = pix2 + line_size;
  2243. s = 0;
  2244. for(i=0;i<16;i++) {
  2245. s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
  2246. s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
  2247. s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
  2248. s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
  2249. s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
  2250. s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
  2251. s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
  2252. s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
  2253. s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
  2254. s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
  2255. s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
  2256. s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
  2257. s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
  2258. s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
  2259. s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
  2260. s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
  2261. pix1 += line_size;
  2262. pix2 += line_size;
  2263. pix3 += line_size;
  2264. }
  2265. return s;
  2266. }
  2267. static inline int pix_abs8x8_c(uint8_t *pix1, uint8_t *pix2, int line_size)
  2268. {
  2269. int s, i;
  2270. s = 0;
  2271. for(i=0;i<8;i++) {
  2272. s += abs(pix1[0] - pix2[0]);
  2273. s += abs(pix1[1] - pix2[1]);
  2274. s += abs(pix1[2] - pix2[2]);
  2275. s += abs(pix1[3] - pix2[3]);
  2276. s += abs(pix1[4] - pix2[4]);
  2277. s += abs(pix1[5] - pix2[5]);
  2278. s += abs(pix1[6] - pix2[6]);
  2279. s += abs(pix1[7] - pix2[7]);
  2280. pix1 += line_size;
  2281. pix2 += line_size;
  2282. }
  2283. return s;
  2284. }
  2285. static int pix_abs8x8_x2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
  2286. {
  2287. int s, i;
  2288. s = 0;
  2289. for(i=0;i<8;i++) {
  2290. s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
  2291. s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
  2292. s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
  2293. s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
  2294. s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
  2295. s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
  2296. s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
  2297. s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
  2298. pix1 += line_size;
  2299. pix2 += line_size;
  2300. }
  2301. return s;
  2302. }
  2303. static int pix_abs8x8_y2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
  2304. {
  2305. int s, i;
  2306. uint8_t *pix3 = pix2 + line_size;
  2307. s = 0;
  2308. for(i=0;i<8;i++) {
  2309. s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
  2310. s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
  2311. s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
  2312. s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
  2313. s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
  2314. s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
  2315. s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
  2316. s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
  2317. pix1 += line_size;
  2318. pix2 += line_size;
  2319. pix3 += line_size;
  2320. }
  2321. return s;
  2322. }
  2323. static int pix_abs8x8_xy2_c(uint8_t *pix1, uint8_t *pix2, int line_size)
  2324. {
  2325. int s, i;
  2326. uint8_t *pix3 = pix2 + line_size;
  2327. s = 0;
  2328. for(i=0;i<8;i++) {
  2329. s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
  2330. s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
  2331. s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
  2332. s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
  2333. s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
  2334. s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
  2335. s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
  2336. s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
  2337. pix1 += line_size;
  2338. pix2 += line_size;
  2339. pix3 += line_size;
  2340. }
  2341. return s;
  2342. }
  2343. static int sad16x16_c(void *s, uint8_t *a, uint8_t *b, int stride){
  2344. return pix_abs16x16_c(a,b,stride);
  2345. }
  2346. static int sad8x8_c(void *s, uint8_t *a, uint8_t *b, int stride){
  2347. return pix_abs8x8_c(a,b,stride);
  2348. }
  2349. /**
  2350. * permutes an 8x8 block.
  2351. * @param block the block which will be permuted according to the given permutation vector
  2352. * @param permutation the permutation vector
  2353. * @param last the last non zero coefficient in scantable order, used to speed the permutation up
  2354. * @param scantable the used scantable, this is only used to speed the permutation up, the block is not
  2355. * (inverse) permutated to scantable order!
  2356. */
  2357. void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last)
  2358. {
  2359. int i;
  2360. DCTELEM temp[64];
  2361. if(last<=0) return;
  2362. //if(permutation[1]==1) return; //FIXME its ok but not clean and might fail for some perms
  2363. for(i=0; i<=last; i++){
  2364. const int j= scantable[i];
  2365. temp[j]= block[j];
  2366. block[j]=0;
  2367. }
  2368. for(i=0; i<=last; i++){
  2369. const int j= scantable[i];
  2370. const int perm_j= permutation[j];
  2371. block[perm_j]= temp[j];
  2372. }
  2373. }
  2374. /**
  2375. * memset(blocks, 0, sizeof(DCTELEM)*6*64)
  2376. */
  2377. static void clear_blocks_c(DCTELEM *blocks)
  2378. {
  2379. memset(blocks, 0, sizeof(DCTELEM)*6*64);
  2380. }
  2381. static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
  2382. int i;
  2383. for(i=0; i+7<w; i+=8){
  2384. dst[i+0] += src[i+0];
  2385. dst[i+1] += src[i+1];
  2386. dst[i+2] += src[i+2];
  2387. dst[i+3] += src[i+3];
  2388. dst[i+4] += src[i+4];
  2389. dst[i+5] += src[i+5];
  2390. dst[i+6] += src[i+6];
  2391. dst[i+7] += src[i+7];
  2392. }
  2393. for(; i<w; i++)
  2394. dst[i+0] += src[i+0];
  2395. }
  2396. static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
  2397. int i;
  2398. for(i=0; i+7<w; i+=8){
  2399. dst[i+0] = src1[i+0]-src2[i+0];
  2400. dst[i+1] = src1[i+1]-src2[i+1];
  2401. dst[i+2] = src1[i+2]-src2[i+2];
  2402. dst[i+3] = src1[i+3]-src2[i+3];
  2403. dst[i+4] = src1[i+4]-src2[i+4];
  2404. dst[i+5] = src1[i+5]-src2[i+5];
  2405. dst[i+6] = src1[i+6]-src2[i+6];
  2406. dst[i+7] = src1[i+7]-src2[i+7];
  2407. }
  2408. for(; i<w; i++)
  2409. dst[i+0] = src1[i+0]-src2[i+0];
  2410. }
  2411. static void sub_hfyu_median_prediction_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){
  2412. int i;
  2413. uint8_t l, lt;
  2414. l= *left;
  2415. lt= *left_top;
  2416. for(i=0; i<w; i++){
  2417. const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF);
  2418. lt= src1[i];
  2419. l= src2[i];
  2420. dst[i]= l - pred;
  2421. }
  2422. *left= l;
  2423. *left_top= lt;
  2424. }
  2425. #define BUTTERFLY2(o1,o2,i1,i2) \
  2426. o1= (i1)+(i2);\
  2427. o2= (i1)-(i2);
  2428. #define BUTTERFLY1(x,y) \
  2429. {\
  2430. int a,b;\
  2431. a= x;\
  2432. b= y;\
  2433. x= a+b;\
  2434. y= a-b;\
  2435. }
  2436. #define BUTTERFLYA(x,y) (ABS((x)+(y)) + ABS((x)-(y)))
  2437. static int hadamard8_diff_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride){
  2438. int i;
  2439. int temp[64];
  2440. int sum=0;
  2441. for(i=0; i<8; i++){
  2442. //FIXME try pointer walks
  2443. BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-dst[stride*i+0],src[stride*i+1]-dst[stride*i+1]);
  2444. BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-dst[stride*i+2],src[stride*i+3]-dst[stride*i+3]);
  2445. BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-dst[stride*i+4],src[stride*i+5]-dst[stride*i+5]);
  2446. BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-dst[stride*i+6],src[stride*i+7]-dst[stride*i+7]);
  2447. BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
  2448. BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
  2449. BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
  2450. BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
  2451. BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
  2452. BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
  2453. BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
  2454. BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
  2455. }
  2456. for(i=0; i<8; i++){
  2457. BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
  2458. BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
  2459. BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
  2460. BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
  2461. BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
  2462. BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
  2463. BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
  2464. BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
  2465. sum +=
  2466. BUTTERFLYA(temp[8*0+i], temp[8*4+i])
  2467. +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
  2468. +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
  2469. +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
  2470. }
  2471. #if 0
  2472. static int maxi=0;
  2473. if(sum>maxi){
  2474. maxi=sum;
  2475. printf("MAX:%d\n", maxi);
  2476. }
  2477. #endif
  2478. return sum;
  2479. }
  2480. static int hadamard8_abs_c(uint8_t *src, int stride, int mean){
  2481. int i;
  2482. int temp[64];
  2483. int sum=0;
  2484. //FIXME OOOPS ignore 0 term instead of mean mess
  2485. for(i=0; i<8; i++){
  2486. //FIXME try pointer walks
  2487. BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-mean,src[stride*i+1]-mean);
  2488. BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-mean,src[stride*i+3]-mean);
  2489. BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-mean,src[stride*i+5]-mean);
  2490. BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-mean,src[stride*i+7]-mean);
  2491. BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
  2492. BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
  2493. BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
  2494. BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
  2495. BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
  2496. BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
  2497. BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
  2498. BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
  2499. }
  2500. for(i=0; i<8; i++){
  2501. BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
  2502. BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
  2503. BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
  2504. BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
  2505. BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
  2506. BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
  2507. BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
  2508. BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
  2509. sum +=
  2510. BUTTERFLYA(temp[8*0+i], temp[8*4+i])
  2511. +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
  2512. +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
  2513. +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
  2514. }
  2515. return sum;
  2516. }
  2517. static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride){
  2518. MpegEncContext * const s= (MpegEncContext *)c;
  2519. uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
  2520. DCTELEM * const temp= (DCTELEM*)aligned_temp;
  2521. int sum=0, i;
  2522. s->dsp.diff_pixels(temp, src1, src2, stride);
  2523. s->dsp.fdct(temp);
  2524. for(i=0; i<64; i++)
  2525. sum+= ABS(temp[i]);
  2526. return sum;
  2527. }
  2528. void simple_idct(DCTELEM *block); //FIXME
  2529. static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride){
  2530. MpegEncContext * const s= (MpegEncContext *)c;
  2531. uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64*2/8];
  2532. DCTELEM * const temp= (DCTELEM*)aligned_temp;
  2533. DCTELEM * const bak = ((DCTELEM*)aligned_temp)+64;
  2534. int sum=0, i;
  2535. s->mb_intra=0;
  2536. s->dsp.diff_pixels(temp, src1, src2, stride);
  2537. memcpy(bak, temp, 64*sizeof(DCTELEM));
  2538. s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
  2539. s->dct_unquantize(s, temp, 0, s->qscale);
  2540. simple_idct(temp); //FIXME
  2541. for(i=0; i<64; i++)
  2542. sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
  2543. return sum;
  2544. }
  2545. static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride){
  2546. MpegEncContext * const s= (MpegEncContext *)c;
  2547. const uint8_t *scantable= s->intra_scantable.permutated;
  2548. uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
  2549. uint64_t __align8 aligned_bak[stride];
  2550. DCTELEM * const temp= (DCTELEM*)aligned_temp;
  2551. uint8_t * const bak= (uint8_t*)aligned_bak;
  2552. int i, last, run, bits, level, distoration, start_i;
  2553. const int esc_length= s->ac_esc_length;
  2554. uint8_t * length;
  2555. uint8_t * last_length;
  2556. for(i=0; i<8; i++){
  2557. ((uint32_t*)(bak + i*stride))[0]= ((uint32_t*)(src2 + i*stride))[0];
  2558. ((uint32_t*)(bak + i*stride))[1]= ((uint32_t*)(src2 + i*stride))[1];
  2559. }
  2560. s->dsp.diff_pixels(temp, src1, src2, stride);
  2561. s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
  2562. bits=0;
  2563. if (s->mb_intra) {
  2564. start_i = 1;
  2565. length = s->intra_ac_vlc_length;
  2566. last_length= s->intra_ac_vlc_last_length;
  2567. bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
  2568. } else {
  2569. start_i = 0;
  2570. length = s->inter_ac_vlc_length;
  2571. last_length= s->inter_ac_vlc_last_length;
  2572. }
  2573. if(last>=start_i){
  2574. run=0;
  2575. for(i=start_i; i<last; i++){
  2576. int j= scantable[i];
  2577. level= temp[j];
  2578. if(level){
  2579. level+=64;
  2580. if((level&(~127)) == 0){
  2581. bits+= length[UNI_AC_ENC_INDEX(run, level)];
  2582. }else
  2583. bits+= esc_length;
  2584. run=0;
  2585. }else
  2586. run++;
  2587. }
  2588. i= scantable[last];
  2589. level= temp[i] + 64;
  2590. assert(level - 64);
  2591. if((level&(~127)) == 0){
  2592. bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
  2593. }else
  2594. bits+= esc_length;
  2595. }
  2596. if(last>=0){
  2597. s->dct_unquantize(s, temp, 0, s->qscale);
  2598. }
  2599. s->dsp.idct_add(bak, stride, temp);
  2600. distoration= s->dsp.sse[1](NULL, bak, src1, stride);
  2601. return distoration + ((bits*s->qscale*s->qscale*109 + 64)>>7);
  2602. }
  2603. static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride){
  2604. MpegEncContext * const s= (MpegEncContext *)c;
  2605. const uint8_t *scantable= s->intra_scantable.permutated;
  2606. uint64_t __align8 aligned_temp[sizeof(DCTELEM)*64/8];
  2607. DCTELEM * const temp= (DCTELEM*)aligned_temp;
  2608. int i, last, run, bits, level, start_i;
  2609. const int esc_length= s->ac_esc_length;
  2610. uint8_t * length;
  2611. uint8_t * last_length;
  2612. s->dsp.diff_pixels(temp, src1, src2, stride);
  2613. s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
  2614. bits=0;
  2615. if (s->mb_intra) {
  2616. start_i = 1;
  2617. length = s->intra_ac_vlc_length;
  2618. last_length= s->intra_ac_vlc_last_length;
  2619. bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
  2620. } else {
  2621. start_i = 0;
  2622. length = s->inter_ac_vlc_length;
  2623. last_length= s->inter_ac_vlc_last_length;
  2624. }
  2625. if(last>=start_i){
  2626. run=0;
  2627. for(i=start_i; i<last; i++){
  2628. int j= scantable[i];
  2629. level= temp[j];
  2630. if(level){
  2631. level+=64;
  2632. if((level&(~127)) == 0){
  2633. bits+= length[UNI_AC_ENC_INDEX(run, level)];
  2634. }else
  2635. bits+= esc_length;
  2636. run=0;
  2637. }else
  2638. run++;
  2639. }
  2640. i= scantable[last];
  2641. level= temp[i] + 64;
  2642. assert(level - 64);
  2643. if((level&(~127)) == 0){
  2644. bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
  2645. }else
  2646. bits+= esc_length;
  2647. }
  2648. return bits;
  2649. }
  2650. WARPER88_1616(hadamard8_diff_c, hadamard8_diff16_c)
  2651. WARPER88_1616(dct_sad8x8_c, dct_sad16x16_c)
  2652. WARPER88_1616(quant_psnr8x8_c, quant_psnr16x16_c)
  2653. WARPER88_1616(rd8x8_c, rd16x16_c)
  2654. WARPER88_1616(bit8x8_c, bit16x16_c)
  2655. /* XXX: those functions should be suppressed ASAP when all IDCTs are
  2656. converted */
  2657. static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
  2658. {
  2659. j_rev_dct (block);
  2660. put_pixels_clamped_c(block, dest, line_size);
  2661. }
  2662. static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block)
  2663. {
  2664. j_rev_dct (block);
  2665. add_pixels_clamped_c(block, dest, line_size);
  2666. }
  2667. /* init static data */
  2668. void dsputil_static_init(void)
  2669. {
  2670. int i;
  2671. for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i;
  2672. for(i=0;i<MAX_NEG_CROP;i++) {
  2673. cropTbl[i] = 0;
  2674. cropTbl[i + MAX_NEG_CROP + 256] = 255;
  2675. }
  2676. for(i=0;i<512;i++) {
  2677. squareTbl[i] = (i - 256) * (i - 256);
  2678. }
  2679. for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
  2680. }
  2681. void dsputil_init(DSPContext* c, AVCodecContext *avctx)
  2682. {
  2683. int i;
  2684. #ifdef CONFIG_ENCODERS
  2685. if(avctx->dct_algo==FF_DCT_FASTINT)
  2686. c->fdct = fdct_ifast;
  2687. else if(avctx->dct_algo==FF_DCT_FAAN)
  2688. c->fdct = ff_faandct;
  2689. else
  2690. c->fdct = ff_jpeg_fdct_islow; //slow/accurate/default
  2691. #endif //CONFIG_ENCODERS
  2692. if(avctx->idct_algo==FF_IDCT_INT){
  2693. c->idct_put= ff_jref_idct_put;
  2694. c->idct_add= ff_jref_idct_add;
  2695. c->idct = j_rev_dct;
  2696. c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
  2697. }else{ //accurate/default
  2698. c->idct_put= simple_idct_put;
  2699. c->idct_add= simple_idct_add;
  2700. c->idct = simple_idct;
  2701. c->idct_permutation_type= FF_NO_IDCT_PERM;
  2702. }
  2703. c->get_pixels = get_pixels_c;
  2704. c->diff_pixels = diff_pixels_c;
  2705. c->put_pixels_clamped = put_pixels_clamped_c;
  2706. c->add_pixels_clamped = add_pixels_clamped_c;
  2707. c->gmc1 = gmc1_c;
  2708. c->gmc = gmc_c;
  2709. c->clear_blocks = clear_blocks_c;
  2710. c->pix_sum = pix_sum_c;
  2711. c->pix_norm1 = pix_norm1_c;
  2712. c->sse[0]= sse16_c;
  2713. c->sse[1]= sse8_c;
  2714. /* TODO [0] 16 [1] 8 */
  2715. c->pix_abs16x16 = pix_abs16x16_c;
  2716. c->pix_abs16x16_x2 = pix_abs16x16_x2_c;
  2717. c->pix_abs16x16_y2 = pix_abs16x16_y2_c;
  2718. c->pix_abs16x16_xy2 = pix_abs16x16_xy2_c;
  2719. c->pix_abs8x8 = pix_abs8x8_c;
  2720. c->pix_abs8x8_x2 = pix_abs8x8_x2_c;
  2721. c->pix_abs8x8_y2 = pix_abs8x8_y2_c;
  2722. c->pix_abs8x8_xy2 = pix_abs8x8_xy2_c;
  2723. #define dspfunc(PFX, IDX, NUM) \
  2724. c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## NUM ## _c; \
  2725. c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## NUM ## _x2_c; \
  2726. c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## NUM ## _y2_c; \
  2727. c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## NUM ## _xy2_c
  2728. dspfunc(put, 0, 16);
  2729. dspfunc(put_no_rnd, 0, 16);
  2730. dspfunc(put, 1, 8);
  2731. dspfunc(put_no_rnd, 1, 8);
  2732. dspfunc(put, 2, 4);
  2733. dspfunc(put, 3, 2);
  2734. dspfunc(avg, 0, 16);
  2735. dspfunc(avg_no_rnd, 0, 16);
  2736. dspfunc(avg, 1, 8);
  2737. dspfunc(avg_no_rnd, 1, 8);
  2738. dspfunc(avg, 2, 4);
  2739. dspfunc(avg, 3, 2);
  2740. #undef dspfunc
  2741. c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
  2742. c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
  2743. c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
  2744. c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
  2745. c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
  2746. c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
  2747. c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
  2748. c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
  2749. c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
  2750. c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
  2751. c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
  2752. c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
  2753. c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
  2754. c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
  2755. c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
  2756. c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
  2757. c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
  2758. c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
  2759. #define dspfunc(PFX, IDX, NUM) \
  2760. c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
  2761. c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
  2762. c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
  2763. c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
  2764. c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
  2765. c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
  2766. c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
  2767. c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
  2768. c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
  2769. c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
  2770. c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
  2771. c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
  2772. c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
  2773. c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
  2774. c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
  2775. c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
  2776. dspfunc(put_qpel, 0, 16);
  2777. dspfunc(put_no_rnd_qpel, 0, 16);
  2778. dspfunc(avg_qpel, 0, 16);
  2779. /* dspfunc(avg_no_rnd_qpel, 0, 16); */
  2780. dspfunc(put_qpel, 1, 8);
  2781. dspfunc(put_no_rnd_qpel, 1, 8);
  2782. dspfunc(avg_qpel, 1, 8);
  2783. /* dspfunc(avg_no_rnd_qpel, 1, 8); */
  2784. dspfunc(put_h264_qpel, 0, 16);
  2785. dspfunc(put_h264_qpel, 1, 8);
  2786. dspfunc(put_h264_qpel, 2, 4);
  2787. dspfunc(avg_h264_qpel, 0, 16);
  2788. dspfunc(avg_h264_qpel, 1, 8);
  2789. dspfunc(avg_h264_qpel, 2, 4);
  2790. #undef dspfunc
  2791. c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c;
  2792. c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c;
  2793. c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c;
  2794. c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c;
  2795. c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c;
  2796. c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c;
  2797. c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
  2798. c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
  2799. c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
  2800. c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
  2801. c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
  2802. c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
  2803. c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
  2804. c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
  2805. c->hadamard8_diff[0]= hadamard8_diff16_c;
  2806. c->hadamard8_diff[1]= hadamard8_diff_c;
  2807. c->hadamard8_abs = hadamard8_abs_c;
  2808. c->dct_sad[0]= dct_sad16x16_c;
  2809. c->dct_sad[1]= dct_sad8x8_c;
  2810. c->sad[0]= sad16x16_c;
  2811. c->sad[1]= sad8x8_c;
  2812. c->quant_psnr[0]= quant_psnr16x16_c;
  2813. c->quant_psnr[1]= quant_psnr8x8_c;
  2814. c->rd[0]= rd16x16_c;
  2815. c->rd[1]= rd8x8_c;
  2816. c->bit[0]= bit16x16_c;
  2817. c->bit[1]= bit8x8_c;
  2818. c->add_bytes= add_bytes_c;
  2819. c->diff_bytes= diff_bytes_c;
  2820. c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
  2821. c->bswap_buf= bswap_buf;
  2822. #ifdef HAVE_MMX
  2823. dsputil_init_mmx(c, avctx);
  2824. #endif
  2825. #ifdef ARCH_ARMV4L
  2826. dsputil_init_armv4l(c, avctx);
  2827. #endif
  2828. #ifdef HAVE_MLIB
  2829. dsputil_init_mlib(c, avctx);
  2830. #endif
  2831. #ifdef ARCH_ALPHA
  2832. dsputil_init_alpha(c, avctx);
  2833. #endif
  2834. #ifdef ARCH_POWERPC
  2835. dsputil_init_ppc(c, avctx);
  2836. #endif
  2837. #ifdef HAVE_MMI
  2838. dsputil_init_mmi(c, avctx);
  2839. #endif
  2840. #ifdef ARCH_SH4
  2841. dsputil_init_sh4(c,avctx);
  2842. #endif
  2843. switch(c->idct_permutation_type){
  2844. case FF_NO_IDCT_PERM:
  2845. for(i=0; i<64; i++)
  2846. c->idct_permutation[i]= i;
  2847. break;
  2848. case FF_LIBMPEG2_IDCT_PERM:
  2849. for(i=0; i<64; i++)
  2850. c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
  2851. break;
  2852. case FF_SIMPLE_IDCT_PERM:
  2853. for(i=0; i<64; i++)
  2854. c->idct_permutation[i]= simple_mmx_permutation[i];
  2855. break;
  2856. case FF_TRANSPOSE_IDCT_PERM:
  2857. for(i=0; i<64; i++)
  2858. c->idct_permutation[i]= ((i&7)<<3) | (i>>3);
  2859. break;
  2860. default:
  2861. fprintf(stderr, "Internal error, IDCT permutation not set\n");
  2862. }
  2863. }