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.

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