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.

2946 lines
98KB

  1. /*
  2. * DSP utils
  3. * Copyright (c) 2000, 2001 Fabrice Bellard
  4. * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  5. *
  6. * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
  7. *
  8. * This file is part of FFmpeg.
  9. *
  10. * FFmpeg is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * FFmpeg is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with FFmpeg; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. /**
  25. * @file
  26. * DSP utils
  27. */
  28. #include "libavutil/attributes.h"
  29. #include "libavutil/imgutils.h"
  30. #include "libavutil/internal.h"
  31. #include "avcodec.h"
  32. #include "copy_block.h"
  33. #include "dct.h"
  34. #include "dsputil.h"
  35. #include "simple_idct.h"
  36. #include "faandct.h"
  37. #include "faanidct.h"
  38. #include "imgconvert.h"
  39. #include "mathops.h"
  40. #include "mpegvideo.h"
  41. #include "config.h"
  42. #include "diracdsp.h"
  43. uint32_t ff_squareTbl[512] = {0, };
  44. #define BIT_DEPTH 16
  45. #include "dsputil_template.c"
  46. #undef BIT_DEPTH
  47. #define BIT_DEPTH 8
  48. #include "dsputil_template.c"
  49. // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
  50. #define pb_7f (~0UL/255 * 0x7f)
  51. #define pb_80 (~0UL/255 * 0x80)
  52. /* Specific zigzag scan for 248 idct. NOTE that unlike the
  53. specification, we interleave the fields */
  54. const uint8_t ff_zigzag248_direct[64] = {
  55. 0, 8, 1, 9, 16, 24, 2, 10,
  56. 17, 25, 32, 40, 48, 56, 33, 41,
  57. 18, 26, 3, 11, 4, 12, 19, 27,
  58. 34, 42, 49, 57, 50, 58, 35, 43,
  59. 20, 28, 5, 13, 6, 14, 21, 29,
  60. 36, 44, 51, 59, 52, 60, 37, 45,
  61. 22, 30, 7, 15, 23, 31, 38, 46,
  62. 53, 61, 54, 62, 39, 47, 55, 63,
  63. };
  64. /* not permutated inverse zigzag_direct + 1 for MMX quantizer */
  65. DECLARE_ALIGNED(16, uint16_t, ff_inv_zigzag_direct16)[64];
  66. const uint8_t ff_alternate_horizontal_scan[64] = {
  67. 0, 1, 2, 3, 8, 9, 16, 17,
  68. 10, 11, 4, 5, 6, 7, 15, 14,
  69. 13, 12, 19, 18, 24, 25, 32, 33,
  70. 26, 27, 20, 21, 22, 23, 28, 29,
  71. 30, 31, 34, 35, 40, 41, 48, 49,
  72. 42, 43, 36, 37, 38, 39, 44, 45,
  73. 46, 47, 50, 51, 56, 57, 58, 59,
  74. 52, 53, 54, 55, 60, 61, 62, 63,
  75. };
  76. const uint8_t ff_alternate_vertical_scan[64] = {
  77. 0, 8, 16, 24, 1, 9, 2, 10,
  78. 17, 25, 32, 40, 48, 56, 57, 49,
  79. 41, 33, 26, 18, 3, 11, 4, 12,
  80. 19, 27, 34, 42, 50, 58, 35, 43,
  81. 51, 59, 20, 28, 5, 13, 6, 14,
  82. 21, 29, 36, 44, 52, 60, 37, 45,
  83. 53, 61, 22, 30, 7, 15, 23, 31,
  84. 38, 46, 54, 62, 39, 47, 55, 63,
  85. };
  86. /* Input permutation for the simple_idct_mmx */
  87. static const uint8_t simple_mmx_permutation[64]={
  88. 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
  89. 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
  90. 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
  91. 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
  92. 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
  93. 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
  94. 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
  95. 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
  96. };
  97. static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7};
  98. av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
  99. const uint8_t *src_scantable)
  100. {
  101. int i;
  102. int end;
  103. st->scantable= src_scantable;
  104. for(i=0; i<64; i++){
  105. int j;
  106. j = src_scantable[i];
  107. st->permutated[i] = permutation[j];
  108. }
  109. end=-1;
  110. for(i=0; i<64; i++){
  111. int j;
  112. j = st->permutated[i];
  113. if(j>end) end=j;
  114. st->raster_end[i]= end;
  115. }
  116. }
  117. av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
  118. int idct_permutation_type)
  119. {
  120. int i;
  121. switch(idct_permutation_type){
  122. case FF_NO_IDCT_PERM:
  123. for(i=0; i<64; i++)
  124. idct_permutation[i]= i;
  125. break;
  126. case FF_LIBMPEG2_IDCT_PERM:
  127. for(i=0; i<64; i++)
  128. idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
  129. break;
  130. case FF_SIMPLE_IDCT_PERM:
  131. for(i=0; i<64; i++)
  132. idct_permutation[i]= simple_mmx_permutation[i];
  133. break;
  134. case FF_TRANSPOSE_IDCT_PERM:
  135. for(i=0; i<64; i++)
  136. idct_permutation[i]= ((i&7)<<3) | (i>>3);
  137. break;
  138. case FF_PARTTRANS_IDCT_PERM:
  139. for(i=0; i<64; i++)
  140. idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
  141. break;
  142. case FF_SSE2_IDCT_PERM:
  143. for(i=0; i<64; i++)
  144. idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7];
  145. break;
  146. default:
  147. av_log(NULL, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
  148. }
  149. }
  150. static int pix_sum_c(uint8_t * pix, int line_size)
  151. {
  152. int s, i, j;
  153. s = 0;
  154. for (i = 0; i < 16; i++) {
  155. for (j = 0; j < 16; j += 8) {
  156. s += pix[0];
  157. s += pix[1];
  158. s += pix[2];
  159. s += pix[3];
  160. s += pix[4];
  161. s += pix[5];
  162. s += pix[6];
  163. s += pix[7];
  164. pix += 8;
  165. }
  166. pix += line_size - 16;
  167. }
  168. return s;
  169. }
  170. static int pix_norm1_c(uint8_t * pix, int line_size)
  171. {
  172. int s, i, j;
  173. uint32_t *sq = ff_squareTbl + 256;
  174. s = 0;
  175. for (i = 0; i < 16; i++) {
  176. for (j = 0; j < 16; j += 8) {
  177. #if 0
  178. s += sq[pix[0]];
  179. s += sq[pix[1]];
  180. s += sq[pix[2]];
  181. s += sq[pix[3]];
  182. s += sq[pix[4]];
  183. s += sq[pix[5]];
  184. s += sq[pix[6]];
  185. s += sq[pix[7]];
  186. #else
  187. #if HAVE_FAST_64BIT
  188. register uint64_t x=*(uint64_t*)pix;
  189. s += sq[x&0xff];
  190. s += sq[(x>>8)&0xff];
  191. s += sq[(x>>16)&0xff];
  192. s += sq[(x>>24)&0xff];
  193. s += sq[(x>>32)&0xff];
  194. s += sq[(x>>40)&0xff];
  195. s += sq[(x>>48)&0xff];
  196. s += sq[(x>>56)&0xff];
  197. #else
  198. register uint32_t x=*(uint32_t*)pix;
  199. s += sq[x&0xff];
  200. s += sq[(x>>8)&0xff];
  201. s += sq[(x>>16)&0xff];
  202. s += sq[(x>>24)&0xff];
  203. x=*(uint32_t*)(pix+4);
  204. s += sq[x&0xff];
  205. s += sq[(x>>8)&0xff];
  206. s += sq[(x>>16)&0xff];
  207. s += sq[(x>>24)&0xff];
  208. #endif
  209. #endif
  210. pix += 8;
  211. }
  212. pix += line_size - 16;
  213. }
  214. return s;
  215. }
  216. static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){
  217. int i;
  218. for(i=0; i+8<=w; i+=8){
  219. dst[i+0]= av_bswap32(src[i+0]);
  220. dst[i+1]= av_bswap32(src[i+1]);
  221. dst[i+2]= av_bswap32(src[i+2]);
  222. dst[i+3]= av_bswap32(src[i+3]);
  223. dst[i+4]= av_bswap32(src[i+4]);
  224. dst[i+5]= av_bswap32(src[i+5]);
  225. dst[i+6]= av_bswap32(src[i+6]);
  226. dst[i+7]= av_bswap32(src[i+7]);
  227. }
  228. for(;i<w; i++){
  229. dst[i+0]= av_bswap32(src[i+0]);
  230. }
  231. }
  232. static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
  233. {
  234. while (len--)
  235. *dst++ = av_bswap16(*src++);
  236. }
  237. static int sse4_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
  238. {
  239. int s, i;
  240. uint32_t *sq = ff_squareTbl + 256;
  241. s = 0;
  242. for (i = 0; i < h; i++) {
  243. s += sq[pix1[0] - pix2[0]];
  244. s += sq[pix1[1] - pix2[1]];
  245. s += sq[pix1[2] - pix2[2]];
  246. s += sq[pix1[3] - pix2[3]];
  247. pix1 += line_size;
  248. pix2 += line_size;
  249. }
  250. return s;
  251. }
  252. static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
  253. {
  254. int s, i;
  255. uint32_t *sq = ff_squareTbl + 256;
  256. s = 0;
  257. for (i = 0; i < h; i++) {
  258. s += sq[pix1[0] - pix2[0]];
  259. s += sq[pix1[1] - pix2[1]];
  260. s += sq[pix1[2] - pix2[2]];
  261. s += sq[pix1[3] - pix2[3]];
  262. s += sq[pix1[4] - pix2[4]];
  263. s += sq[pix1[5] - pix2[5]];
  264. s += sq[pix1[6] - pix2[6]];
  265. s += sq[pix1[7] - pix2[7]];
  266. pix1 += line_size;
  267. pix2 += line_size;
  268. }
  269. return s;
  270. }
  271. static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  272. {
  273. int s, i;
  274. uint32_t *sq = ff_squareTbl + 256;
  275. s = 0;
  276. for (i = 0; i < h; i++) {
  277. s += sq[pix1[ 0] - pix2[ 0]];
  278. s += sq[pix1[ 1] - pix2[ 1]];
  279. s += sq[pix1[ 2] - pix2[ 2]];
  280. s += sq[pix1[ 3] - pix2[ 3]];
  281. s += sq[pix1[ 4] - pix2[ 4]];
  282. s += sq[pix1[ 5] - pix2[ 5]];
  283. s += sq[pix1[ 6] - pix2[ 6]];
  284. s += sq[pix1[ 7] - pix2[ 7]];
  285. s += sq[pix1[ 8] - pix2[ 8]];
  286. s += sq[pix1[ 9] - pix2[ 9]];
  287. s += sq[pix1[10] - pix2[10]];
  288. s += sq[pix1[11] - pix2[11]];
  289. s += sq[pix1[12] - pix2[12]];
  290. s += sq[pix1[13] - pix2[13]];
  291. s += sq[pix1[14] - pix2[14]];
  292. s += sq[pix1[15] - pix2[15]];
  293. pix1 += line_size;
  294. pix2 += line_size;
  295. }
  296. return s;
  297. }
  298. static void diff_pixels_c(int16_t *av_restrict block, const uint8_t *s1,
  299. const uint8_t *s2, int stride){
  300. int i;
  301. /* read the pixels */
  302. for(i=0;i<8;i++) {
  303. block[0] = s1[0] - s2[0];
  304. block[1] = s1[1] - s2[1];
  305. block[2] = s1[2] - s2[2];
  306. block[3] = s1[3] - s2[3];
  307. block[4] = s1[4] - s2[4];
  308. block[5] = s1[5] - s2[5];
  309. block[6] = s1[6] - s2[6];
  310. block[7] = s1[7] - s2[7];
  311. s1 += stride;
  312. s2 += stride;
  313. block += 8;
  314. }
  315. }
  316. static void put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
  317. int line_size)
  318. {
  319. int i;
  320. /* read the pixels */
  321. for(i=0;i<8;i++) {
  322. pixels[0] = av_clip_uint8(block[0]);
  323. pixels[1] = av_clip_uint8(block[1]);
  324. pixels[2] = av_clip_uint8(block[2]);
  325. pixels[3] = av_clip_uint8(block[3]);
  326. pixels[4] = av_clip_uint8(block[4]);
  327. pixels[5] = av_clip_uint8(block[5]);
  328. pixels[6] = av_clip_uint8(block[6]);
  329. pixels[7] = av_clip_uint8(block[7]);
  330. pixels += line_size;
  331. block += 8;
  332. }
  333. }
  334. static void put_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels,
  335. int line_size)
  336. {
  337. int i;
  338. /* read the pixels */
  339. for(i=0;i<4;i++) {
  340. pixels[0] = av_clip_uint8(block[0]);
  341. pixels[1] = av_clip_uint8(block[1]);
  342. pixels[2] = av_clip_uint8(block[2]);
  343. pixels[3] = av_clip_uint8(block[3]);
  344. pixels += line_size;
  345. block += 8;
  346. }
  347. }
  348. static void put_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pixels,
  349. int line_size)
  350. {
  351. int i;
  352. /* read the pixels */
  353. for(i=0;i<2;i++) {
  354. pixels[0] = av_clip_uint8(block[0]);
  355. pixels[1] = av_clip_uint8(block[1]);
  356. pixels += line_size;
  357. block += 8;
  358. }
  359. }
  360. static void put_signed_pixels_clamped_c(const int16_t *block,
  361. uint8_t *av_restrict pixels,
  362. int line_size)
  363. {
  364. int i, j;
  365. for (i = 0; i < 8; i++) {
  366. for (j = 0; j < 8; j++) {
  367. if (*block < -128)
  368. *pixels = 0;
  369. else if (*block > 127)
  370. *pixels = 255;
  371. else
  372. *pixels = (uint8_t)(*block + 128);
  373. block++;
  374. pixels++;
  375. }
  376. pixels += (line_size - 8);
  377. }
  378. }
  379. static void add_pixels8_c(uint8_t *av_restrict pixels,
  380. int16_t *block,
  381. int line_size)
  382. {
  383. int i;
  384. for(i=0;i<8;i++) {
  385. pixels[0] += block[0];
  386. pixels[1] += block[1];
  387. pixels[2] += block[2];
  388. pixels[3] += block[3];
  389. pixels[4] += block[4];
  390. pixels[5] += block[5];
  391. pixels[6] += block[6];
  392. pixels[7] += block[7];
  393. pixels += line_size;
  394. block += 8;
  395. }
  396. }
  397. static void add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
  398. int line_size)
  399. {
  400. int i;
  401. /* read the pixels */
  402. for(i=0;i<8;i++) {
  403. pixels[0] = av_clip_uint8(pixels[0] + block[0]);
  404. pixels[1] = av_clip_uint8(pixels[1] + block[1]);
  405. pixels[2] = av_clip_uint8(pixels[2] + block[2]);
  406. pixels[3] = av_clip_uint8(pixels[3] + block[3]);
  407. pixels[4] = av_clip_uint8(pixels[4] + block[4]);
  408. pixels[5] = av_clip_uint8(pixels[5] + block[5]);
  409. pixels[6] = av_clip_uint8(pixels[6] + block[6]);
  410. pixels[7] = av_clip_uint8(pixels[7] + block[7]);
  411. pixels += line_size;
  412. block += 8;
  413. }
  414. }
  415. static void add_pixels_clamped4_c(const int16_t *block, uint8_t *av_restrict pixels,
  416. int line_size)
  417. {
  418. int i;
  419. /* read the pixels */
  420. for(i=0;i<4;i++) {
  421. pixels[0] = av_clip_uint8(pixels[0] + block[0]);
  422. pixels[1] = av_clip_uint8(pixels[1] + block[1]);
  423. pixels[2] = av_clip_uint8(pixels[2] + block[2]);
  424. pixels[3] = av_clip_uint8(pixels[3] + block[3]);
  425. pixels += line_size;
  426. block += 8;
  427. }
  428. }
  429. static void add_pixels_clamped2_c(const int16_t *block, uint8_t *av_restrict pixels,
  430. int line_size)
  431. {
  432. int i;
  433. /* read the pixels */
  434. for(i=0;i<2;i++) {
  435. pixels[0] = av_clip_uint8(pixels[0] + block[0]);
  436. pixels[1] = av_clip_uint8(pixels[1] + block[1]);
  437. pixels += line_size;
  438. block += 8;
  439. }
  440. }
  441. static int sum_abs_dctelem_c(int16_t *block)
  442. {
  443. int sum=0, i;
  444. for(i=0; i<64; i++)
  445. sum+= FFABS(block[i]);
  446. return sum;
  447. }
  448. static void fill_block16_c(uint8_t *block, uint8_t value, int line_size, int h)
  449. {
  450. int i;
  451. for (i = 0; i < h; i++) {
  452. memset(block, value, 16);
  453. block += line_size;
  454. }
  455. }
  456. static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h)
  457. {
  458. int i;
  459. for (i = 0; i < h; i++) {
  460. memset(block, value, 8);
  461. block += line_size;
  462. }
  463. }
  464. #define avg2(a,b) ((a+b+1)>>1)
  465. #define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
  466. static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder)
  467. {
  468. const int A=(16-x16)*(16-y16);
  469. const int B=( x16)*(16-y16);
  470. const int C=(16-x16)*( y16);
  471. const int D=( x16)*( y16);
  472. int i;
  473. for(i=0; i<h; i++)
  474. {
  475. dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8;
  476. dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8;
  477. dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8;
  478. dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8;
  479. dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8;
  480. dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8;
  481. dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8;
  482. dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8;
  483. dst+= stride;
  484. src+= stride;
  485. }
  486. }
  487. void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
  488. int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
  489. {
  490. int y, vx, vy;
  491. const int s= 1<<shift;
  492. width--;
  493. height--;
  494. for(y=0; y<h; y++){
  495. int x;
  496. vx= ox;
  497. vy= oy;
  498. for(x=0; x<8; x++){ //XXX FIXME optimize
  499. int src_x, src_y, frac_x, frac_y, index;
  500. src_x= vx>>16;
  501. src_y= vy>>16;
  502. frac_x= src_x&(s-1);
  503. frac_y= src_y&(s-1);
  504. src_x>>=shift;
  505. src_y>>=shift;
  506. if((unsigned)src_x < width){
  507. if((unsigned)src_y < height){
  508. index= src_x + src_y*stride;
  509. dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
  510. + src[index +1]* frac_x )*(s-frac_y)
  511. + ( src[index+stride ]*(s-frac_x)
  512. + src[index+stride+1]* frac_x )* frac_y
  513. + r)>>(shift*2);
  514. }else{
  515. index= src_x + av_clip(src_y, 0, height)*stride;
  516. dst[y*stride + x]= ( ( src[index ]*(s-frac_x)
  517. + src[index +1]* frac_x )*s
  518. + r)>>(shift*2);
  519. }
  520. }else{
  521. if((unsigned)src_y < height){
  522. index= av_clip(src_x, 0, width) + src_y*stride;
  523. dst[y*stride + x]= ( ( src[index ]*(s-frac_y)
  524. + src[index+stride ]* frac_y )*s
  525. + r)>>(shift*2);
  526. }else{
  527. index= av_clip(src_x, 0, width) + av_clip(src_y, 0, height)*stride;
  528. dst[y*stride + x]= src[index ];
  529. }
  530. }
  531. vx+= dxx;
  532. vy+= dyx;
  533. }
  534. ox += dxy;
  535. oy += dyy;
  536. }
  537. }
  538. static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  539. switch(width){
  540. case 2: put_pixels2_8_c (dst, src, stride, height); break;
  541. case 4: put_pixels4_8_c (dst, src, stride, height); break;
  542. case 8: put_pixels8_8_c (dst, src, stride, height); break;
  543. case 16:put_pixels16_8_c(dst, src, stride, height); break;
  544. }
  545. }
  546. static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  547. int i,j;
  548. for (i=0; i < height; i++) {
  549. for (j=0; j < width; j++) {
  550. dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11;
  551. }
  552. src += stride;
  553. dst += stride;
  554. }
  555. }
  556. static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  557. int i,j;
  558. for (i=0; i < height; i++) {
  559. for (j=0; j < width; j++) {
  560. dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11;
  561. }
  562. src += stride;
  563. dst += stride;
  564. }
  565. }
  566. static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  567. int i,j;
  568. for (i=0; i < height; i++) {
  569. for (j=0; j < width; j++) {
  570. dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11;
  571. }
  572. src += stride;
  573. dst += stride;
  574. }
  575. }
  576. static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  577. int i,j;
  578. for (i=0; i < height; i++) {
  579. for (j=0; j < width; j++) {
  580. dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15;
  581. }
  582. src += stride;
  583. dst += stride;
  584. }
  585. }
  586. static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  587. int i,j;
  588. for (i=0; i < height; i++) {
  589. for (j=0; j < width; j++) {
  590. dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
  591. }
  592. src += stride;
  593. dst += stride;
  594. }
  595. }
  596. static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  597. int i,j;
  598. for (i=0; i < height; i++) {
  599. for (j=0; j < width; j++) {
  600. dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11;
  601. }
  602. src += stride;
  603. dst += stride;
  604. }
  605. }
  606. static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  607. int i,j;
  608. for (i=0; i < height; i++) {
  609. for (j=0; j < width; j++) {
  610. dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
  611. }
  612. src += stride;
  613. dst += stride;
  614. }
  615. }
  616. static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  617. int i,j;
  618. for (i=0; i < height; i++) {
  619. for (j=0; j < width; j++) {
  620. dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15;
  621. }
  622. src += stride;
  623. dst += stride;
  624. }
  625. }
  626. static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  627. switch(width){
  628. case 2: avg_pixels2_8_c (dst, src, stride, height); break;
  629. case 4: avg_pixels4_8_c (dst, src, stride, height); break;
  630. case 8: avg_pixels8_8_c (dst, src, stride, height); break;
  631. case 16:avg_pixels16_8_c(dst, src, stride, height); break;
  632. }
  633. }
  634. static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  635. int i,j;
  636. for (i=0; i < height; i++) {
  637. for (j=0; j < width; j++) {
  638. dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1;
  639. }
  640. src += stride;
  641. dst += stride;
  642. }
  643. }
  644. static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  645. int i,j;
  646. for (i=0; i < height; i++) {
  647. for (j=0; j < width; j++) {
  648. dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1;
  649. }
  650. src += stride;
  651. dst += stride;
  652. }
  653. }
  654. static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  655. int i,j;
  656. for (i=0; i < height; i++) {
  657. for (j=0; j < width; j++) {
  658. dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1;
  659. }
  660. src += stride;
  661. dst += stride;
  662. }
  663. }
  664. static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  665. int i,j;
  666. for (i=0; i < height; i++) {
  667. for (j=0; j < width; j++) {
  668. 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;
  669. }
  670. src += stride;
  671. dst += stride;
  672. }
  673. }
  674. static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  675. int i,j;
  676. for (i=0; i < height; i++) {
  677. for (j=0; j < width; j++) {
  678. 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;
  679. }
  680. src += stride;
  681. dst += stride;
  682. }
  683. }
  684. static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  685. int i,j;
  686. for (i=0; i < height; i++) {
  687. for (j=0; j < width; j++) {
  688. dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1;
  689. }
  690. src += stride;
  691. dst += stride;
  692. }
  693. }
  694. static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  695. int i,j;
  696. for (i=0; i < height; i++) {
  697. for (j=0; j < width; j++) {
  698. 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;
  699. }
  700. src += stride;
  701. dst += stride;
  702. }
  703. }
  704. static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
  705. int i,j;
  706. for (i=0; i < height; i++) {
  707. for (j=0; j < width; j++) {
  708. 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;
  709. }
  710. src += stride;
  711. dst += stride;
  712. }
  713. }
  714. #define QPEL_MC(r, OPNAME, RND, OP) \
  715. static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
  716. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
  717. int i;\
  718. for(i=0; i<h; i++)\
  719. {\
  720. OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\
  721. OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\
  722. OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\
  723. OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\
  724. OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\
  725. OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\
  726. OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\
  727. OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\
  728. dst+=dstStride;\
  729. src+=srcStride;\
  730. }\
  731. }\
  732. \
  733. static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  734. const int w=8;\
  735. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
  736. int i;\
  737. for(i=0; i<w; i++)\
  738. {\
  739. const int src0= src[0*srcStride];\
  740. const int src1= src[1*srcStride];\
  741. const int src2= src[2*srcStride];\
  742. const int src3= src[3*srcStride];\
  743. const int src4= src[4*srcStride];\
  744. const int src5= src[5*srcStride];\
  745. const int src6= src[6*srcStride];\
  746. const int src7= src[7*srcStride];\
  747. const int src8= src[8*srcStride];\
  748. OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\
  749. OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\
  750. OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\
  751. OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\
  752. OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\
  753. OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\
  754. OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\
  755. OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\
  756. dst++;\
  757. src++;\
  758. }\
  759. }\
  760. \
  761. static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
  762. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
  763. int i;\
  764. \
  765. for(i=0; i<h; i++)\
  766. {\
  767. OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\
  768. OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\
  769. OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\
  770. OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\
  771. OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\
  772. OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\
  773. OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\
  774. OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\
  775. OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\
  776. OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\
  777. OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\
  778. OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\
  779. OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\
  780. OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\
  781. OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\
  782. OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\
  783. dst+=dstStride;\
  784. src+=srcStride;\
  785. }\
  786. }\
  787. \
  788. static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
  789. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
  790. int i;\
  791. const int w=16;\
  792. for(i=0; i<w; i++)\
  793. {\
  794. const int src0= src[0*srcStride];\
  795. const int src1= src[1*srcStride];\
  796. const int src2= src[2*srcStride];\
  797. const int src3= src[3*srcStride];\
  798. const int src4= src[4*srcStride];\
  799. const int src5= src[5*srcStride];\
  800. const int src6= src[6*srcStride];\
  801. const int src7= src[7*srcStride];\
  802. const int src8= src[8*srcStride];\
  803. const int src9= src[9*srcStride];\
  804. const int src10= src[10*srcStride];\
  805. const int src11= src[11*srcStride];\
  806. const int src12= src[12*srcStride];\
  807. const int src13= src[13*srcStride];\
  808. const int src14= src[14*srcStride];\
  809. const int src15= src[15*srcStride];\
  810. const int src16= src[16*srcStride];\
  811. OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\
  812. OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\
  813. OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\
  814. OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\
  815. OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\
  816. OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\
  817. OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\
  818. OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\
  819. OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\
  820. OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\
  821. OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\
  822. OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\
  823. OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\
  824. OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\
  825. OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\
  826. OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\
  827. dst++;\
  828. src++;\
  829. }\
  830. }\
  831. \
  832. static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  833. {\
  834. uint8_t half[64];\
  835. put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
  836. OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8);\
  837. }\
  838. \
  839. static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  840. {\
  841. OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
  842. }\
  843. \
  844. static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  845. {\
  846. uint8_t half[64];\
  847. put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
  848. OPNAME ## pixels8_l2_8(dst, src+1, half, stride, stride, 8, 8);\
  849. }\
  850. \
  851. static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  852. {\
  853. uint8_t full[16*9];\
  854. uint8_t half[64];\
  855. copy_block9(full, src, 16, stride, 9);\
  856. put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
  857. OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8);\
  858. }\
  859. \
  860. static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  861. {\
  862. uint8_t full[16*9];\
  863. copy_block9(full, src, 16, stride, 9);\
  864. OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\
  865. }\
  866. \
  867. static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  868. {\
  869. uint8_t full[16*9];\
  870. uint8_t half[64];\
  871. copy_block9(full, src, 16, stride, 9);\
  872. put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
  873. OPNAME ## pixels8_l2_8(dst, full+16, half, stride, 16, 8, 8);\
  874. }\
  875. void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  876. {\
  877. uint8_t full[16*9];\
  878. uint8_t halfH[72];\
  879. uint8_t halfV[64];\
  880. uint8_t halfHV[64];\
  881. copy_block9(full, src, 16, stride, 9);\
  882. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  883. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
  884. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  885. OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
  886. }\
  887. static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  888. {\
  889. uint8_t full[16*9];\
  890. uint8_t halfH[72];\
  891. uint8_t halfHV[64];\
  892. copy_block9(full, src, 16, stride, 9);\
  893. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  894. put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
  895. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  896. OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
  897. }\
  898. void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  899. {\
  900. uint8_t full[16*9];\
  901. uint8_t halfH[72];\
  902. uint8_t halfV[64];\
  903. uint8_t halfHV[64];\
  904. copy_block9(full, src, 16, stride, 9);\
  905. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  906. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
  907. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  908. OPNAME ## pixels8_l4_8(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
  909. }\
  910. static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  911. {\
  912. uint8_t full[16*9];\
  913. uint8_t halfH[72];\
  914. uint8_t halfHV[64];\
  915. copy_block9(full, src, 16, stride, 9);\
  916. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  917. put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
  918. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  919. OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
  920. }\
  921. void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  922. {\
  923. uint8_t full[16*9];\
  924. uint8_t halfH[72];\
  925. uint8_t halfV[64];\
  926. uint8_t halfHV[64];\
  927. copy_block9(full, src, 16, stride, 9);\
  928. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  929. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
  930. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  931. OPNAME ## pixels8_l4_8(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
  932. }\
  933. static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  934. {\
  935. uint8_t full[16*9];\
  936. uint8_t halfH[72];\
  937. uint8_t halfHV[64];\
  938. copy_block9(full, src, 16, stride, 9);\
  939. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  940. put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
  941. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  942. OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
  943. }\
  944. void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  945. {\
  946. uint8_t full[16*9];\
  947. uint8_t halfH[72];\
  948. uint8_t halfV[64];\
  949. uint8_t halfHV[64];\
  950. copy_block9(full, src, 16, stride, 9);\
  951. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\
  952. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
  953. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  954. OPNAME ## pixels8_l4_8(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
  955. }\
  956. static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  957. {\
  958. uint8_t full[16*9];\
  959. uint8_t halfH[72];\
  960. uint8_t halfHV[64];\
  961. copy_block9(full, src, 16, stride, 9);\
  962. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  963. put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
  964. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  965. OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
  966. }\
  967. static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  968. {\
  969. uint8_t halfH[72];\
  970. uint8_t halfHV[64];\
  971. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
  972. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  973. OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
  974. }\
  975. static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  976. {\
  977. uint8_t halfH[72];\
  978. uint8_t halfHV[64];\
  979. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
  980. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  981. OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
  982. }\
  983. void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  984. {\
  985. uint8_t full[16*9];\
  986. uint8_t halfH[72];\
  987. uint8_t halfV[64];\
  988. uint8_t halfHV[64];\
  989. copy_block9(full, src, 16, stride, 9);\
  990. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  991. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
  992. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  993. OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);\
  994. }\
  995. static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  996. {\
  997. uint8_t full[16*9];\
  998. uint8_t halfH[72];\
  999. copy_block9(full, src, 16, stride, 9);\
  1000. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1001. put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
  1002. OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
  1003. }\
  1004. void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1005. {\
  1006. uint8_t full[16*9];\
  1007. uint8_t halfH[72];\
  1008. uint8_t halfV[64];\
  1009. uint8_t halfHV[64];\
  1010. copy_block9(full, src, 16, stride, 9);\
  1011. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1012. put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
  1013. put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
  1014. OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);\
  1015. }\
  1016. static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1017. {\
  1018. uint8_t full[16*9];\
  1019. uint8_t halfH[72];\
  1020. copy_block9(full, src, 16, stride, 9);\
  1021. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
  1022. put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
  1023. OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
  1024. }\
  1025. static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1026. {\
  1027. uint8_t halfH[72];\
  1028. put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
  1029. OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
  1030. }\
  1031. \
  1032. static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1033. {\
  1034. uint8_t half[256];\
  1035. put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
  1036. OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16);\
  1037. }\
  1038. \
  1039. static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1040. {\
  1041. OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
  1042. }\
  1043. \
  1044. static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1045. {\
  1046. uint8_t half[256];\
  1047. put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
  1048. OPNAME ## pixels16_l2_8(dst, src+1, half, stride, stride, 16, 16);\
  1049. }\
  1050. \
  1051. static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1052. {\
  1053. uint8_t full[24*17];\
  1054. uint8_t half[256];\
  1055. copy_block17(full, src, 24, stride, 17);\
  1056. put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
  1057. OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16);\
  1058. }\
  1059. \
  1060. static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1061. {\
  1062. uint8_t full[24*17];\
  1063. copy_block17(full, src, 24, stride, 17);\
  1064. OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\
  1065. }\
  1066. \
  1067. static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1068. {\
  1069. uint8_t full[24*17];\
  1070. uint8_t half[256];\
  1071. copy_block17(full, src, 24, stride, 17);\
  1072. put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
  1073. OPNAME ## pixels16_l2_8(dst, full+24, half, stride, 24, 16, 16);\
  1074. }\
  1075. void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1076. {\
  1077. uint8_t full[24*17];\
  1078. uint8_t halfH[272];\
  1079. uint8_t halfV[256];\
  1080. uint8_t halfHV[256];\
  1081. copy_block17(full, src, 24, stride, 17);\
  1082. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1083. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
  1084. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1085. OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
  1086. }\
  1087. static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1088. {\
  1089. uint8_t full[24*17];\
  1090. uint8_t halfH[272];\
  1091. uint8_t halfHV[256];\
  1092. copy_block17(full, src, 24, stride, 17);\
  1093. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1094. put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
  1095. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1096. OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
  1097. }\
  1098. void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1099. {\
  1100. uint8_t full[24*17];\
  1101. uint8_t halfH[272];\
  1102. uint8_t halfV[256];\
  1103. uint8_t halfHV[256];\
  1104. copy_block17(full, src, 24, stride, 17);\
  1105. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1106. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
  1107. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1108. OPNAME ## pixels16_l4_8(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
  1109. }\
  1110. static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1111. {\
  1112. uint8_t full[24*17];\
  1113. uint8_t halfH[272];\
  1114. uint8_t halfHV[256];\
  1115. copy_block17(full, src, 24, stride, 17);\
  1116. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1117. put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
  1118. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1119. OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
  1120. }\
  1121. void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1122. {\
  1123. uint8_t full[24*17];\
  1124. uint8_t halfH[272];\
  1125. uint8_t halfV[256];\
  1126. uint8_t halfHV[256];\
  1127. copy_block17(full, src, 24, stride, 17);\
  1128. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1129. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
  1130. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1131. OPNAME ## pixels16_l4_8(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
  1132. }\
  1133. static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1134. {\
  1135. uint8_t full[24*17];\
  1136. uint8_t halfH[272];\
  1137. uint8_t halfHV[256];\
  1138. copy_block17(full, src, 24, stride, 17);\
  1139. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1140. put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
  1141. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1142. OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
  1143. }\
  1144. void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1145. {\
  1146. uint8_t full[24*17];\
  1147. uint8_t halfH[272];\
  1148. uint8_t halfV[256];\
  1149. uint8_t halfHV[256];\
  1150. copy_block17(full, src, 24, stride, 17);\
  1151. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\
  1152. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
  1153. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1154. OPNAME ## pixels16_l4_8(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
  1155. }\
  1156. static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1157. {\
  1158. uint8_t full[24*17];\
  1159. uint8_t halfH[272];\
  1160. uint8_t halfHV[256];\
  1161. copy_block17(full, src, 24, stride, 17);\
  1162. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1163. put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
  1164. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1165. OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
  1166. }\
  1167. static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1168. {\
  1169. uint8_t halfH[272];\
  1170. uint8_t halfHV[256];\
  1171. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
  1172. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1173. OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
  1174. }\
  1175. static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1176. {\
  1177. uint8_t halfH[272];\
  1178. uint8_t halfHV[256];\
  1179. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
  1180. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1181. OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
  1182. }\
  1183. void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1184. {\
  1185. uint8_t full[24*17];\
  1186. uint8_t halfH[272];\
  1187. uint8_t halfV[256];\
  1188. uint8_t halfHV[256];\
  1189. copy_block17(full, src, 24, stride, 17);\
  1190. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1191. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
  1192. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1193. OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);\
  1194. }\
  1195. static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1196. {\
  1197. uint8_t full[24*17];\
  1198. uint8_t halfH[272];\
  1199. copy_block17(full, src, 24, stride, 17);\
  1200. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1201. put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
  1202. OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
  1203. }\
  1204. void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1205. {\
  1206. uint8_t full[24*17];\
  1207. uint8_t halfH[272];\
  1208. uint8_t halfV[256];\
  1209. uint8_t halfHV[256];\
  1210. copy_block17(full, src, 24, stride, 17);\
  1211. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1212. put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
  1213. put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
  1214. OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);\
  1215. }\
  1216. static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1217. {\
  1218. uint8_t full[24*17];\
  1219. uint8_t halfH[272];\
  1220. copy_block17(full, src, 24, stride, 17);\
  1221. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
  1222. put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
  1223. OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
  1224. }\
  1225. static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
  1226. {\
  1227. uint8_t halfH[272];\
  1228. put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
  1229. OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
  1230. }
  1231. #define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
  1232. #define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1)
  1233. #define op_put(a, b) a = cm[((b) + 16)>>5]
  1234. #define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5]
  1235. QPEL_MC(0, put_ , _ , op_put)
  1236. QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
  1237. QPEL_MC(0, avg_ , _ , op_avg)
  1238. //QPEL_MC(1, avg_no_rnd , _ , op_avg)
  1239. #undef op_avg
  1240. #undef op_avg_no_rnd
  1241. #undef op_put
  1242. #undef op_put_no_rnd
  1243. void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1244. {
  1245. put_pixels8_8_c(dst, src, stride, 8);
  1246. }
  1247. void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1248. {
  1249. avg_pixels8_8_c(dst, src, stride, 8);
  1250. }
  1251. void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1252. {
  1253. put_pixels16_8_c(dst, src, stride, 16);
  1254. }
  1255. void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1256. {
  1257. avg_pixels16_8_c(dst, src, stride, 16);
  1258. }
  1259. #define put_qpel8_mc00_c ff_put_pixels8x8_c
  1260. #define avg_qpel8_mc00_c ff_avg_pixels8x8_c
  1261. #define put_qpel16_mc00_c ff_put_pixels16x16_c
  1262. #define avg_qpel16_mc00_c ff_avg_pixels16x16_c
  1263. #define put_no_rnd_qpel8_mc00_c ff_put_pixels8x8_c
  1264. #define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
  1265. static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
  1266. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  1267. int i;
  1268. for(i=0; i<h; i++){
  1269. dst[0]= cm[(9*(src[0] + src[1]) - (src[-1] + src[2]) + 8)>>4];
  1270. dst[1]= cm[(9*(src[1] + src[2]) - (src[ 0] + src[3]) + 8)>>4];
  1271. dst[2]= cm[(9*(src[2] + src[3]) - (src[ 1] + src[4]) + 8)>>4];
  1272. dst[3]= cm[(9*(src[3] + src[4]) - (src[ 2] + src[5]) + 8)>>4];
  1273. dst[4]= cm[(9*(src[4] + src[5]) - (src[ 3] + src[6]) + 8)>>4];
  1274. dst[5]= cm[(9*(src[5] + src[6]) - (src[ 4] + src[7]) + 8)>>4];
  1275. dst[6]= cm[(9*(src[6] + src[7]) - (src[ 5] + src[8]) + 8)>>4];
  1276. dst[7]= cm[(9*(src[7] + src[8]) - (src[ 6] + src[9]) + 8)>>4];
  1277. dst+=dstStride;
  1278. src+=srcStride;
  1279. }
  1280. }
  1281. #if CONFIG_RV40_DECODER
  1282. void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1283. {
  1284. put_pixels16_xy2_8_c(dst, src, stride, 16);
  1285. }
  1286. void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1287. {
  1288. avg_pixels16_xy2_8_c(dst, src, stride, 16);
  1289. }
  1290. void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1291. {
  1292. put_pixels8_xy2_8_c(dst, src, stride, 8);
  1293. }
  1294. void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1295. {
  1296. avg_pixels8_xy2_8_c(dst, src, stride, 8);
  1297. }
  1298. #endif /* CONFIG_RV40_DECODER */
  1299. #if CONFIG_DIRAC_DECODER
  1300. #define DIRAC_MC(OPNAME)\
  1301. void ff_ ## OPNAME ## _dirac_pixels8_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1302. {\
  1303. OPNAME ## _pixels8_8_c(dst, src[0], stride, h);\
  1304. }\
  1305. void ff_ ## OPNAME ## _dirac_pixels16_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1306. {\
  1307. OPNAME ## _pixels16_8_c(dst, src[0], stride, h);\
  1308. }\
  1309. void ff_ ## OPNAME ## _dirac_pixels32_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1310. {\
  1311. OPNAME ## _pixels16_8_c(dst , src[0] , stride, h);\
  1312. OPNAME ## _pixels16_8_c(dst+16, src[0]+16, stride, h);\
  1313. }\
  1314. void ff_ ## OPNAME ## _dirac_pixels8_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1315. {\
  1316. OPNAME ## _pixels8_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
  1317. }\
  1318. void ff_ ## OPNAME ## _dirac_pixels16_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1319. {\
  1320. OPNAME ## _pixels16_l2_8(dst, src[0], src[1], stride, stride, stride, h);\
  1321. }\
  1322. void ff_ ## OPNAME ## _dirac_pixels32_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1323. {\
  1324. OPNAME ## _pixels16_l2_8(dst , src[0] , src[1] , stride, stride, stride, h);\
  1325. OPNAME ## _pixels16_l2_8(dst+16, src[0]+16, src[1]+16, stride, stride, stride, h);\
  1326. }\
  1327. void ff_ ## OPNAME ## _dirac_pixels8_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1328. {\
  1329. OPNAME ## _pixels8_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
  1330. }\
  1331. void ff_ ## OPNAME ## _dirac_pixels16_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1332. {\
  1333. OPNAME ## _pixels16_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\
  1334. }\
  1335. void ff_ ## OPNAME ## _dirac_pixels32_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
  1336. {\
  1337. OPNAME ## _pixels16_l4_8(dst , src[0] , src[1] , src[2] , src[3] , stride, stride, stride, stride, stride, h);\
  1338. OPNAME ## _pixels16_l4_8(dst+16, src[0]+16, src[1]+16, src[2]+16, src[3]+16, stride, stride, stride, stride, stride, h);\
  1339. }
  1340. DIRAC_MC(put)
  1341. DIRAC_MC(avg)
  1342. #endif
  1343. static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
  1344. const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
  1345. int i;
  1346. for(i=0; i<w; i++){
  1347. const int src_1= src[ -srcStride];
  1348. const int src0 = src[0 ];
  1349. const int src1 = src[ srcStride];
  1350. const int src2 = src[2*srcStride];
  1351. const int src3 = src[3*srcStride];
  1352. const int src4 = src[4*srcStride];
  1353. const int src5 = src[5*srcStride];
  1354. const int src6 = src[6*srcStride];
  1355. const int src7 = src[7*srcStride];
  1356. const int src8 = src[8*srcStride];
  1357. const int src9 = src[9*srcStride];
  1358. dst[0*dstStride]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4];
  1359. dst[1*dstStride]= cm[(9*(src1 + src2) - (src0 + src3) + 8)>>4];
  1360. dst[2*dstStride]= cm[(9*(src2 + src3) - (src1 + src4) + 8)>>4];
  1361. dst[3*dstStride]= cm[(9*(src3 + src4) - (src2 + src5) + 8)>>4];
  1362. dst[4*dstStride]= cm[(9*(src4 + src5) - (src3 + src6) + 8)>>4];
  1363. dst[5*dstStride]= cm[(9*(src5 + src6) - (src4 + src7) + 8)>>4];
  1364. dst[6*dstStride]= cm[(9*(src6 + src7) - (src5 + src8) + 8)>>4];
  1365. dst[7*dstStride]= cm[(9*(src7 + src8) - (src6 + src9) + 8)>>4];
  1366. src++;
  1367. dst++;
  1368. }
  1369. }
  1370. static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1371. {
  1372. uint8_t half[64];
  1373. wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
  1374. put_pixels8_l2_8(dst, src, half, stride, stride, 8, 8);
  1375. }
  1376. static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1377. {
  1378. wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8);
  1379. }
  1380. static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1381. {
  1382. uint8_t half[64];
  1383. wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
  1384. put_pixels8_l2_8(dst, src+1, half, stride, stride, 8, 8);
  1385. }
  1386. static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1387. {
  1388. wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8);
  1389. }
  1390. static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1391. {
  1392. uint8_t halfH[88];
  1393. uint8_t halfV[64];
  1394. uint8_t halfHV[64];
  1395. wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
  1396. wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
  1397. wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
  1398. put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
  1399. }
  1400. static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1401. {
  1402. uint8_t halfH[88];
  1403. uint8_t halfV[64];
  1404. uint8_t halfHV[64];
  1405. wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
  1406. wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8);
  1407. wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
  1408. put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
  1409. }
  1410. static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
  1411. {
  1412. uint8_t halfH[88];
  1413. wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
  1414. wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
  1415. }
  1416. static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
  1417. if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
  1418. int x;
  1419. const int strength= ff_h263_loop_filter_strength[qscale];
  1420. for(x=0; x<8; x++){
  1421. int d1, d2, ad1;
  1422. int p0= src[x-2*stride];
  1423. int p1= src[x-1*stride];
  1424. int p2= src[x+0*stride];
  1425. int p3= src[x+1*stride];
  1426. int d = (p0 - p3 + 4*(p2 - p1)) / 8;
  1427. if (d<-2*strength) d1= 0;
  1428. else if(d<- strength) d1=-2*strength - d;
  1429. else if(d< strength) d1= d;
  1430. else if(d< 2*strength) d1= 2*strength - d;
  1431. else d1= 0;
  1432. p1 += d1;
  1433. p2 -= d1;
  1434. if(p1&256) p1= ~(p1>>31);
  1435. if(p2&256) p2= ~(p2>>31);
  1436. src[x-1*stride] = p1;
  1437. src[x+0*stride] = p2;
  1438. ad1= FFABS(d1)>>1;
  1439. d2= av_clip((p0-p3)/4, -ad1, ad1);
  1440. src[x-2*stride] = p0 - d2;
  1441. src[x+ stride] = p3 + d2;
  1442. }
  1443. }
  1444. }
  1445. static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
  1446. if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
  1447. int y;
  1448. const int strength= ff_h263_loop_filter_strength[qscale];
  1449. for(y=0; y<8; y++){
  1450. int d1, d2, ad1;
  1451. int p0= src[y*stride-2];
  1452. int p1= src[y*stride-1];
  1453. int p2= src[y*stride+0];
  1454. int p3= src[y*stride+1];
  1455. int d = (p0 - p3 + 4*(p2 - p1)) / 8;
  1456. if (d<-2*strength) d1= 0;
  1457. else if(d<- strength) d1=-2*strength - d;
  1458. else if(d< strength) d1= d;
  1459. else if(d< 2*strength) d1= 2*strength - d;
  1460. else d1= 0;
  1461. p1 += d1;
  1462. p2 -= d1;
  1463. if(p1&256) p1= ~(p1>>31);
  1464. if(p2&256) p2= ~(p2>>31);
  1465. src[y*stride-1] = p1;
  1466. src[y*stride+0] = p2;
  1467. ad1= FFABS(d1)>>1;
  1468. d2= av_clip((p0-p3)/4, -ad1, ad1);
  1469. src[y*stride-2] = p0 - d2;
  1470. src[y*stride+1] = p3 + d2;
  1471. }
  1472. }
  1473. }
  1474. static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  1475. {
  1476. int s, i;
  1477. s = 0;
  1478. for(i=0;i<h;i++) {
  1479. s += abs(pix1[0] - pix2[0]);
  1480. s += abs(pix1[1] - pix2[1]);
  1481. s += abs(pix1[2] - pix2[2]);
  1482. s += abs(pix1[3] - pix2[3]);
  1483. s += abs(pix1[4] - pix2[4]);
  1484. s += abs(pix1[5] - pix2[5]);
  1485. s += abs(pix1[6] - pix2[6]);
  1486. s += abs(pix1[7] - pix2[7]);
  1487. s += abs(pix1[8] - pix2[8]);
  1488. s += abs(pix1[9] - pix2[9]);
  1489. s += abs(pix1[10] - pix2[10]);
  1490. s += abs(pix1[11] - pix2[11]);
  1491. s += abs(pix1[12] - pix2[12]);
  1492. s += abs(pix1[13] - pix2[13]);
  1493. s += abs(pix1[14] - pix2[14]);
  1494. s += abs(pix1[15] - pix2[15]);
  1495. pix1 += line_size;
  1496. pix2 += line_size;
  1497. }
  1498. return s;
  1499. }
  1500. static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  1501. {
  1502. int s, i;
  1503. s = 0;
  1504. for(i=0;i<h;i++) {
  1505. s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
  1506. s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
  1507. s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
  1508. s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
  1509. s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
  1510. s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
  1511. s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
  1512. s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
  1513. s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
  1514. s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
  1515. s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
  1516. s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
  1517. s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
  1518. s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
  1519. s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
  1520. s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
  1521. pix1 += line_size;
  1522. pix2 += line_size;
  1523. }
  1524. return s;
  1525. }
  1526. static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  1527. {
  1528. int s, i;
  1529. uint8_t *pix3 = pix2 + line_size;
  1530. s = 0;
  1531. for(i=0;i<h;i++) {
  1532. s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
  1533. s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
  1534. s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
  1535. s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
  1536. s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
  1537. s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
  1538. s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
  1539. s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
  1540. s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
  1541. s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
  1542. s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
  1543. s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
  1544. s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
  1545. s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
  1546. s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
  1547. s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
  1548. pix1 += line_size;
  1549. pix2 += line_size;
  1550. pix3 += line_size;
  1551. }
  1552. return s;
  1553. }
  1554. static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  1555. {
  1556. int s, i;
  1557. uint8_t *pix3 = pix2 + line_size;
  1558. s = 0;
  1559. for(i=0;i<h;i++) {
  1560. s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
  1561. s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
  1562. s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
  1563. s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
  1564. s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
  1565. s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
  1566. s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
  1567. s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
  1568. s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
  1569. s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
  1570. s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
  1571. s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
  1572. s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
  1573. s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
  1574. s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
  1575. s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
  1576. pix1 += line_size;
  1577. pix2 += line_size;
  1578. pix3 += line_size;
  1579. }
  1580. return s;
  1581. }
  1582. static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  1583. {
  1584. int s, i;
  1585. s = 0;
  1586. for(i=0;i<h;i++) {
  1587. s += abs(pix1[0] - pix2[0]);
  1588. s += abs(pix1[1] - pix2[1]);
  1589. s += abs(pix1[2] - pix2[2]);
  1590. s += abs(pix1[3] - pix2[3]);
  1591. s += abs(pix1[4] - pix2[4]);
  1592. s += abs(pix1[5] - pix2[5]);
  1593. s += abs(pix1[6] - pix2[6]);
  1594. s += abs(pix1[7] - pix2[7]);
  1595. pix1 += line_size;
  1596. pix2 += line_size;
  1597. }
  1598. return s;
  1599. }
  1600. static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  1601. {
  1602. int s, i;
  1603. s = 0;
  1604. for(i=0;i<h;i++) {
  1605. s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
  1606. s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
  1607. s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
  1608. s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
  1609. s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
  1610. s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
  1611. s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
  1612. s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
  1613. pix1 += line_size;
  1614. pix2 += line_size;
  1615. }
  1616. return s;
  1617. }
  1618. static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  1619. {
  1620. int s, i;
  1621. uint8_t *pix3 = pix2 + line_size;
  1622. s = 0;
  1623. for(i=0;i<h;i++) {
  1624. s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
  1625. s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
  1626. s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
  1627. s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
  1628. s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
  1629. s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
  1630. s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
  1631. s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
  1632. pix1 += line_size;
  1633. pix2 += line_size;
  1634. pix3 += line_size;
  1635. }
  1636. return s;
  1637. }
  1638. static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
  1639. {
  1640. int s, i;
  1641. uint8_t *pix3 = pix2 + line_size;
  1642. s = 0;
  1643. for(i=0;i<h;i++) {
  1644. s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
  1645. s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
  1646. s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
  1647. s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
  1648. s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
  1649. s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
  1650. s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
  1651. s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
  1652. pix1 += line_size;
  1653. pix2 += line_size;
  1654. pix3 += line_size;
  1655. }
  1656. return s;
  1657. }
  1658. static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
  1659. MpegEncContext *c = v;
  1660. int score1=0;
  1661. int score2=0;
  1662. int x,y;
  1663. for(y=0; y<h; y++){
  1664. for(x=0; x<16; x++){
  1665. score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]);
  1666. }
  1667. if(y+1<h){
  1668. for(x=0; x<15; x++){
  1669. score2+= FFABS( s1[x ] - s1[x +stride]
  1670. - s1[x+1] + s1[x+1+stride])
  1671. -FFABS( s2[x ] - s2[x +stride]
  1672. - s2[x+1] + s2[x+1+stride]);
  1673. }
  1674. }
  1675. s1+= stride;
  1676. s2+= stride;
  1677. }
  1678. if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
  1679. else return score1 + FFABS(score2)*8;
  1680. }
  1681. static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
  1682. MpegEncContext *c = v;
  1683. int score1=0;
  1684. int score2=0;
  1685. int x,y;
  1686. for(y=0; y<h; y++){
  1687. for(x=0; x<8; x++){
  1688. score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]);
  1689. }
  1690. if(y+1<h){
  1691. for(x=0; x<7; x++){
  1692. score2+= FFABS( s1[x ] - s1[x +stride]
  1693. - s1[x+1] + s1[x+1+stride])
  1694. -FFABS( s2[x ] - s2[x +stride]
  1695. - s2[x+1] + s2[x+1+stride]);
  1696. }
  1697. }
  1698. s1+= stride;
  1699. s2+= stride;
  1700. }
  1701. if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
  1702. else return score1 + FFABS(score2)*8;
  1703. }
  1704. static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
  1705. int i;
  1706. unsigned int sum=0;
  1707. for(i=0; i<8*8; i++){
  1708. int b= rem[i] + ((basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT));
  1709. int w= weight[i];
  1710. b>>= RECON_SHIFT;
  1711. av_assert2(-512<b && b<512);
  1712. sum += (w*b)*(w*b)>>4;
  1713. }
  1714. return sum>>2;
  1715. }
  1716. static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale){
  1717. int i;
  1718. for(i=0; i<8*8; i++){
  1719. rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
  1720. }
  1721. }
  1722. static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){
  1723. return 0;
  1724. }
  1725. void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
  1726. int i;
  1727. memset(cmp, 0, sizeof(void*)*6);
  1728. for(i=0; i<6; i++){
  1729. switch(type&0xFF){
  1730. case FF_CMP_SAD:
  1731. cmp[i]= c->sad[i];
  1732. break;
  1733. case FF_CMP_SATD:
  1734. cmp[i]= c->hadamard8_diff[i];
  1735. break;
  1736. case FF_CMP_SSE:
  1737. cmp[i]= c->sse[i];
  1738. break;
  1739. case FF_CMP_DCT:
  1740. cmp[i]= c->dct_sad[i];
  1741. break;
  1742. case FF_CMP_DCT264:
  1743. cmp[i]= c->dct264_sad[i];
  1744. break;
  1745. case FF_CMP_DCTMAX:
  1746. cmp[i]= c->dct_max[i];
  1747. break;
  1748. case FF_CMP_PSNR:
  1749. cmp[i]= c->quant_psnr[i];
  1750. break;
  1751. case FF_CMP_BIT:
  1752. cmp[i]= c->bit[i];
  1753. break;
  1754. case FF_CMP_RD:
  1755. cmp[i]= c->rd[i];
  1756. break;
  1757. case FF_CMP_VSAD:
  1758. cmp[i]= c->vsad[i];
  1759. break;
  1760. case FF_CMP_VSSE:
  1761. cmp[i]= c->vsse[i];
  1762. break;
  1763. case FF_CMP_ZERO:
  1764. cmp[i]= zero_cmp;
  1765. break;
  1766. case FF_CMP_NSSE:
  1767. cmp[i]= c->nsse[i];
  1768. break;
  1769. #if CONFIG_DWT
  1770. case FF_CMP_W53:
  1771. cmp[i]= c->w53[i];
  1772. break;
  1773. case FF_CMP_W97:
  1774. cmp[i]= c->w97[i];
  1775. break;
  1776. #endif
  1777. default:
  1778. av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n");
  1779. }
  1780. }
  1781. }
  1782. static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
  1783. long i;
  1784. for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
  1785. long a = *(long*)(src+i);
  1786. long b = *(long*)(dst+i);
  1787. *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
  1788. }
  1789. for(; i<w; i++)
  1790. dst[i+0] += src[i+0];
  1791. }
  1792. static void diff_bytes_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w){
  1793. long i;
  1794. #if !HAVE_FAST_UNALIGNED
  1795. if((long)src2 & (sizeof(long)-1)){
  1796. for(i=0; i+7<w; i+=8){
  1797. dst[i+0] = src1[i+0]-src2[i+0];
  1798. dst[i+1] = src1[i+1]-src2[i+1];
  1799. dst[i+2] = src1[i+2]-src2[i+2];
  1800. dst[i+3] = src1[i+3]-src2[i+3];
  1801. dst[i+4] = src1[i+4]-src2[i+4];
  1802. dst[i+5] = src1[i+5]-src2[i+5];
  1803. dst[i+6] = src1[i+6]-src2[i+6];
  1804. dst[i+7] = src1[i+7]-src2[i+7];
  1805. }
  1806. }else
  1807. #endif
  1808. for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
  1809. long a = *(long*)(src1+i);
  1810. long b = *(long*)(src2+i);
  1811. *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
  1812. }
  1813. for(; i<w; i++)
  1814. dst[i+0] = src1[i+0]-src2[i+0];
  1815. }
  1816. static void add_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *diff, int w, int *left, int *left_top){
  1817. int i;
  1818. uint8_t l, lt;
  1819. l= *left;
  1820. lt= *left_top;
  1821. for(i=0; i<w; i++){
  1822. l= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF) + diff[i];
  1823. lt= src1[i];
  1824. dst[i]= l;
  1825. }
  1826. *left= l;
  1827. *left_top= lt;
  1828. }
  1829. static void sub_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top){
  1830. int i;
  1831. uint8_t l, lt;
  1832. l= *left;
  1833. lt= *left_top;
  1834. for(i=0; i<w; i++){
  1835. const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF);
  1836. lt= src1[i];
  1837. l= src2[i];
  1838. dst[i]= l - pred;
  1839. }
  1840. *left= l;
  1841. *left_top= lt;
  1842. }
  1843. static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src, int w, int acc){
  1844. int i;
  1845. for(i=0; i<w-1; i++){
  1846. acc+= src[i];
  1847. dst[i]= acc;
  1848. i++;
  1849. acc+= src[i];
  1850. dst[i]= acc;
  1851. }
  1852. for(; i<w; i++){
  1853. acc+= src[i];
  1854. dst[i]= acc;
  1855. }
  1856. return acc;
  1857. }
  1858. #if HAVE_BIGENDIAN
  1859. #define B 3
  1860. #define G 2
  1861. #define R 1
  1862. #define A 0
  1863. #else
  1864. #define B 0
  1865. #define G 1
  1866. #define R 2
  1867. #define A 3
  1868. #endif
  1869. static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha){
  1870. int i;
  1871. int r,g,b,a;
  1872. r= *red;
  1873. g= *green;
  1874. b= *blue;
  1875. a= *alpha;
  1876. for(i=0; i<w; i++){
  1877. b+= src[4*i+B];
  1878. g+= src[4*i+G];
  1879. r+= src[4*i+R];
  1880. a+= src[4*i+A];
  1881. dst[4*i+B]= b;
  1882. dst[4*i+G]= g;
  1883. dst[4*i+R]= r;
  1884. dst[4*i+A]= a;
  1885. }
  1886. *red= r;
  1887. *green= g;
  1888. *blue= b;
  1889. *alpha= a;
  1890. }
  1891. #undef B
  1892. #undef G
  1893. #undef R
  1894. #undef A
  1895. #define BUTTERFLY2(o1,o2,i1,i2) \
  1896. o1= (i1)+(i2);\
  1897. o2= (i1)-(i2);
  1898. #define BUTTERFLY1(x,y) \
  1899. {\
  1900. int a,b;\
  1901. a= x;\
  1902. b= y;\
  1903. x= a+b;\
  1904. y= a-b;\
  1905. }
  1906. #define BUTTERFLYA(x,y) (FFABS((x)+(y)) + FFABS((x)-(y)))
  1907. static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
  1908. int i;
  1909. int temp[64];
  1910. int sum=0;
  1911. av_assert2(h==8);
  1912. for(i=0; i<8; i++){
  1913. //FIXME try pointer walks
  1914. 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]);
  1915. 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]);
  1916. 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]);
  1917. 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]);
  1918. BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
  1919. BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
  1920. BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
  1921. BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
  1922. BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
  1923. BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
  1924. BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
  1925. BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
  1926. }
  1927. for(i=0; i<8; i++){
  1928. BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
  1929. BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
  1930. BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
  1931. BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
  1932. BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
  1933. BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
  1934. BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
  1935. BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
  1936. sum +=
  1937. BUTTERFLYA(temp[8*0+i], temp[8*4+i])
  1938. +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
  1939. +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
  1940. +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
  1941. }
  1942. return sum;
  1943. }
  1944. static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_t *dummy, int stride, int h){
  1945. int i;
  1946. int temp[64];
  1947. int sum=0;
  1948. av_assert2(h==8);
  1949. for(i=0; i<8; i++){
  1950. //FIXME try pointer walks
  1951. BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]);
  1952. BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]);
  1953. BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]);
  1954. BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]);
  1955. BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
  1956. BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
  1957. BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
  1958. BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
  1959. BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
  1960. BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
  1961. BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
  1962. BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
  1963. }
  1964. for(i=0; i<8; i++){
  1965. BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
  1966. BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
  1967. BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
  1968. BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
  1969. BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
  1970. BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
  1971. BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
  1972. BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
  1973. sum +=
  1974. BUTTERFLYA(temp[8*0+i], temp[8*4+i])
  1975. +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
  1976. +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
  1977. +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
  1978. }
  1979. sum -= FFABS(temp[8*0] + temp[8*4]); // -mean
  1980. return sum;
  1981. }
  1982. static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
  1983. MpegEncContext * const s= (MpegEncContext *)c;
  1984. LOCAL_ALIGNED_16(int16_t, temp, [64]);
  1985. av_assert2(h==8);
  1986. s->dsp.diff_pixels(temp, src1, src2, stride);
  1987. s->dsp.fdct(temp);
  1988. return s->dsp.sum_abs_dctelem(temp);
  1989. }
  1990. #if CONFIG_GPL
  1991. #define DCT8_1D {\
  1992. const int s07 = SRC(0) + SRC(7);\
  1993. const int s16 = SRC(1) + SRC(6);\
  1994. const int s25 = SRC(2) + SRC(5);\
  1995. const int s34 = SRC(3) + SRC(4);\
  1996. const int a0 = s07 + s34;\
  1997. const int a1 = s16 + s25;\
  1998. const int a2 = s07 - s34;\
  1999. const int a3 = s16 - s25;\
  2000. const int d07 = SRC(0) - SRC(7);\
  2001. const int d16 = SRC(1) - SRC(6);\
  2002. const int d25 = SRC(2) - SRC(5);\
  2003. const int d34 = SRC(3) - SRC(4);\
  2004. const int a4 = d16 + d25 + (d07 + (d07>>1));\
  2005. const int a5 = d07 - d34 - (d25 + (d25>>1));\
  2006. const int a6 = d07 + d34 - (d16 + (d16>>1));\
  2007. const int a7 = d16 - d25 + (d34 + (d34>>1));\
  2008. DST(0, a0 + a1 ) ;\
  2009. DST(1, a4 + (a7>>2)) ;\
  2010. DST(2, a2 + (a3>>1)) ;\
  2011. DST(3, a5 + (a6>>2)) ;\
  2012. DST(4, a0 - a1 ) ;\
  2013. DST(5, a6 - (a5>>2)) ;\
  2014. DST(6, (a2>>1) - a3 ) ;\
  2015. DST(7, (a4>>2) - a7 ) ;\
  2016. }
  2017. static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
  2018. MpegEncContext * const s= (MpegEncContext *)c;
  2019. int16_t dct[8][8];
  2020. int i;
  2021. int sum=0;
  2022. s->dsp.diff_pixels(dct[0], src1, src2, stride);
  2023. #define SRC(x) dct[i][x]
  2024. #define DST(x,v) dct[i][x]= v
  2025. for( i = 0; i < 8; i++ )
  2026. DCT8_1D
  2027. #undef SRC
  2028. #undef DST
  2029. #define SRC(x) dct[x][i]
  2030. #define DST(x,v) sum += FFABS(v)
  2031. for( i = 0; i < 8; i++ )
  2032. DCT8_1D
  2033. #undef SRC
  2034. #undef DST
  2035. return sum;
  2036. }
  2037. #endif
  2038. static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
  2039. MpegEncContext * const s= (MpegEncContext *)c;
  2040. LOCAL_ALIGNED_16(int16_t, temp, [64]);
  2041. int sum=0, i;
  2042. av_assert2(h==8);
  2043. s->dsp.diff_pixels(temp, src1, src2, stride);
  2044. s->dsp.fdct(temp);
  2045. for(i=0; i<64; i++)
  2046. sum= FFMAX(sum, FFABS(temp[i]));
  2047. return sum;
  2048. }
  2049. static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
  2050. MpegEncContext * const s= (MpegEncContext *)c;
  2051. LOCAL_ALIGNED_16(int16_t, temp, [64*2]);
  2052. int16_t * const bak = temp+64;
  2053. int sum=0, i;
  2054. av_assert2(h==8);
  2055. s->mb_intra=0;
  2056. s->dsp.diff_pixels(temp, src1, src2, stride);
  2057. memcpy(bak, temp, 64*sizeof(int16_t));
  2058. s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
  2059. s->dct_unquantize_inter(s, temp, 0, s->qscale);
  2060. ff_simple_idct_8(temp); //FIXME
  2061. for(i=0; i<64; i++)
  2062. sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
  2063. return sum;
  2064. }
  2065. static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
  2066. MpegEncContext * const s= (MpegEncContext *)c;
  2067. const uint8_t *scantable= s->intra_scantable.permutated;
  2068. LOCAL_ALIGNED_16(int16_t, temp, [64]);
  2069. LOCAL_ALIGNED_16(uint8_t, lsrc1, [64]);
  2070. LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]);
  2071. int i, last, run, bits, level, distortion, start_i;
  2072. const int esc_length= s->ac_esc_length;
  2073. uint8_t * length;
  2074. uint8_t * last_length;
  2075. av_assert2(h==8);
  2076. copy_block8(lsrc1, src1, 8, stride, 8);
  2077. copy_block8(lsrc2, src2, 8, stride, 8);
  2078. s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8);
  2079. s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
  2080. bits=0;
  2081. if (s->mb_intra) {
  2082. start_i = 1;
  2083. length = s->intra_ac_vlc_length;
  2084. last_length= s->intra_ac_vlc_last_length;
  2085. bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
  2086. } else {
  2087. start_i = 0;
  2088. length = s->inter_ac_vlc_length;
  2089. last_length= s->inter_ac_vlc_last_length;
  2090. }
  2091. if(last>=start_i){
  2092. run=0;
  2093. for(i=start_i; i<last; i++){
  2094. int j= scantable[i];
  2095. level= temp[j];
  2096. if(level){
  2097. level+=64;
  2098. if((level&(~127)) == 0){
  2099. bits+= length[UNI_AC_ENC_INDEX(run, level)];
  2100. }else
  2101. bits+= esc_length;
  2102. run=0;
  2103. }else
  2104. run++;
  2105. }
  2106. i= scantable[last];
  2107. level= temp[i] + 64;
  2108. av_assert2(level - 64);
  2109. if((level&(~127)) == 0){
  2110. bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
  2111. }else
  2112. bits+= esc_length;
  2113. }
  2114. if(last>=0){
  2115. if(s->mb_intra)
  2116. s->dct_unquantize_intra(s, temp, 0, s->qscale);
  2117. else
  2118. s->dct_unquantize_inter(s, temp, 0, s->qscale);
  2119. }
  2120. s->dsp.idct_add(lsrc2, 8, temp);
  2121. distortion= s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
  2122. return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7);
  2123. }
  2124. static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
  2125. MpegEncContext * const s= (MpegEncContext *)c;
  2126. const uint8_t *scantable= s->intra_scantable.permutated;
  2127. LOCAL_ALIGNED_16(int16_t, temp, [64]);
  2128. int i, last, run, bits, level, start_i;
  2129. const int esc_length= s->ac_esc_length;
  2130. uint8_t * length;
  2131. uint8_t * last_length;
  2132. av_assert2(h==8);
  2133. s->dsp.diff_pixels(temp, src1, src2, stride);
  2134. s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
  2135. bits=0;
  2136. if (s->mb_intra) {
  2137. start_i = 1;
  2138. length = s->intra_ac_vlc_length;
  2139. last_length= s->intra_ac_vlc_last_length;
  2140. bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
  2141. } else {
  2142. start_i = 0;
  2143. length = s->inter_ac_vlc_length;
  2144. last_length= s->inter_ac_vlc_last_length;
  2145. }
  2146. if(last>=start_i){
  2147. run=0;
  2148. for(i=start_i; i<last; i++){
  2149. int j= scantable[i];
  2150. level= temp[j];
  2151. if(level){
  2152. level+=64;
  2153. if((level&(~127)) == 0){
  2154. bits+= length[UNI_AC_ENC_INDEX(run, level)];
  2155. }else
  2156. bits+= esc_length;
  2157. run=0;
  2158. }else
  2159. run++;
  2160. }
  2161. i= scantable[last];
  2162. level= temp[i] + 64;
  2163. av_assert2(level - 64);
  2164. if((level&(~127)) == 0){
  2165. bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
  2166. }else
  2167. bits+= esc_length;
  2168. }
  2169. return bits;
  2170. }
  2171. #define VSAD_INTRA(size) \
  2172. static int vsad_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
  2173. int score=0; \
  2174. int x,y; \
  2175. \
  2176. for(y=1; y<h; y++){ \
  2177. for(x=0; x<size; x+=4){ \
  2178. score+= FFABS(s[x ] - s[x +stride]) + FFABS(s[x+1] - s[x+1+stride]) \
  2179. +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]); \
  2180. } \
  2181. s+= stride; \
  2182. } \
  2183. \
  2184. return score; \
  2185. }
  2186. VSAD_INTRA(8)
  2187. VSAD_INTRA(16)
  2188. static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
  2189. int score=0;
  2190. int x,y;
  2191. for(y=1; y<h; y++){
  2192. for(x=0; x<16; x++){
  2193. score+= FFABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
  2194. }
  2195. s1+= stride;
  2196. s2+= stride;
  2197. }
  2198. return score;
  2199. }
  2200. #define SQ(a) ((a)*(a))
  2201. #define VSSE_INTRA(size) \
  2202. static int vsse_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
  2203. int score=0; \
  2204. int x,y; \
  2205. \
  2206. for(y=1; y<h; y++){ \
  2207. for(x=0; x<size; x+=4){ \
  2208. score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride]) \
  2209. +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]); \
  2210. } \
  2211. s+= stride; \
  2212. } \
  2213. \
  2214. return score; \
  2215. }
  2216. VSSE_INTRA(8)
  2217. VSSE_INTRA(16)
  2218. static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
  2219. int score=0;
  2220. int x,y;
  2221. for(y=1; y<h; y++){
  2222. for(x=0; x<16; x++){
  2223. score+= SQ(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]);
  2224. }
  2225. s1+= stride;
  2226. s2+= stride;
  2227. }
  2228. return score;
  2229. }
  2230. static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2,
  2231. int size){
  2232. int score=0;
  2233. int i;
  2234. for(i=0; i<size; i++)
  2235. score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
  2236. return score;
  2237. }
  2238. #define WRAPPER8_16_SQ(name8, name16)\
  2239. static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
  2240. int score=0;\
  2241. score +=name8(s, dst , src , stride, 8);\
  2242. score +=name8(s, dst+8 , src+8 , stride, 8);\
  2243. if(h==16){\
  2244. dst += 8*stride;\
  2245. src += 8*stride;\
  2246. score +=name8(s, dst , src , stride, 8);\
  2247. score +=name8(s, dst+8 , src+8 , stride, 8);\
  2248. }\
  2249. return score;\
  2250. }
  2251. WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
  2252. WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
  2253. WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
  2254. #if CONFIG_GPL
  2255. WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
  2256. #endif
  2257. WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c)
  2258. WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
  2259. WRAPPER8_16_SQ(rd8x8_c, rd16_c)
  2260. WRAPPER8_16_SQ(bit8x8_c, bit16_c)
  2261. static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini,
  2262. uint32_t maxi, uint32_t maxisign)
  2263. {
  2264. if(a > mini) return mini;
  2265. else if((a^(1U<<31)) > maxisign) return maxi;
  2266. else return a;
  2267. }
  2268. static void vector_clipf_c_opposite_sign(float *dst, const float *src, float *min, float *max, int len){
  2269. int i;
  2270. uint32_t mini = *(uint32_t*)min;
  2271. uint32_t maxi = *(uint32_t*)max;
  2272. uint32_t maxisign = maxi ^ (1U<<31);
  2273. uint32_t *dsti = (uint32_t*)dst;
  2274. const uint32_t *srci = (const uint32_t*)src;
  2275. for(i=0; i<len; i+=8) {
  2276. dsti[i + 0] = clipf_c_one(srci[i + 0], mini, maxi, maxisign);
  2277. dsti[i + 1] = clipf_c_one(srci[i + 1], mini, maxi, maxisign);
  2278. dsti[i + 2] = clipf_c_one(srci[i + 2], mini, maxi, maxisign);
  2279. dsti[i + 3] = clipf_c_one(srci[i + 3], mini, maxi, maxisign);
  2280. dsti[i + 4] = clipf_c_one(srci[i + 4], mini, maxi, maxisign);
  2281. dsti[i + 5] = clipf_c_one(srci[i + 5], mini, maxi, maxisign);
  2282. dsti[i + 6] = clipf_c_one(srci[i + 6], mini, maxi, maxisign);
  2283. dsti[i + 7] = clipf_c_one(srci[i + 7], mini, maxi, maxisign);
  2284. }
  2285. }
  2286. static void vector_clipf_c(float *dst, const float *src, float min, float max, int len){
  2287. int i;
  2288. if(min < 0 && max > 0) {
  2289. vector_clipf_c_opposite_sign(dst, src, &min, &max, len);
  2290. } else {
  2291. for(i=0; i < len; i+=8) {
  2292. dst[i ] = av_clipf(src[i ], min, max);
  2293. dst[i + 1] = av_clipf(src[i + 1], min, max);
  2294. dst[i + 2] = av_clipf(src[i + 2], min, max);
  2295. dst[i + 3] = av_clipf(src[i + 3], min, max);
  2296. dst[i + 4] = av_clipf(src[i + 4], min, max);
  2297. dst[i + 5] = av_clipf(src[i + 5], min, max);
  2298. dst[i + 6] = av_clipf(src[i + 6], min, max);
  2299. dst[i + 7] = av_clipf(src[i + 7], min, max);
  2300. }
  2301. }
  2302. }
  2303. static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int order)
  2304. {
  2305. int res = 0;
  2306. while (order--)
  2307. res += *v1++ * *v2++;
  2308. return res;
  2309. }
  2310. static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul)
  2311. {
  2312. int res = 0;
  2313. while (order--) {
  2314. res += *v1 * *v2++;
  2315. *v1++ += mul * *v3++;
  2316. }
  2317. return res;
  2318. }
  2319. static void apply_window_int16_c(int16_t *output, const int16_t *input,
  2320. const int16_t *window, unsigned int len)
  2321. {
  2322. int i;
  2323. int len2 = len >> 1;
  2324. for (i = 0; i < len2; i++) {
  2325. int16_t w = window[i];
  2326. output[i] = (MUL16(input[i], w) + (1 << 14)) >> 15;
  2327. output[len-i-1] = (MUL16(input[len-i-1], w) + (1 << 14)) >> 15;
  2328. }
  2329. }
  2330. static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
  2331. int32_t max, unsigned int len)
  2332. {
  2333. do {
  2334. *dst++ = av_clip(*src++, min, max);
  2335. *dst++ = av_clip(*src++, min, max);
  2336. *dst++ = av_clip(*src++, min, max);
  2337. *dst++ = av_clip(*src++, min, max);
  2338. *dst++ = av_clip(*src++, min, max);
  2339. *dst++ = av_clip(*src++, min, max);
  2340. *dst++ = av_clip(*src++, min, max);
  2341. *dst++ = av_clip(*src++, min, max);
  2342. len -= 8;
  2343. } while (len > 0);
  2344. }
  2345. static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
  2346. {
  2347. ff_j_rev_dct (block);
  2348. put_pixels_clamped_c(block, dest, line_size);
  2349. }
  2350. static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
  2351. {
  2352. ff_j_rev_dct (block);
  2353. add_pixels_clamped_c(block, dest, line_size);
  2354. }
  2355. static void ff_jref_idct4_put(uint8_t *dest, int line_size, int16_t *block)
  2356. {
  2357. ff_j_rev_dct4 (block);
  2358. put_pixels_clamped4_c(block, dest, line_size);
  2359. }
  2360. static void ff_jref_idct4_add(uint8_t *dest, int line_size, int16_t *block)
  2361. {
  2362. ff_j_rev_dct4 (block);
  2363. add_pixels_clamped4_c(block, dest, line_size);
  2364. }
  2365. static void ff_jref_idct2_put(uint8_t *dest, int line_size, int16_t *block)
  2366. {
  2367. ff_j_rev_dct2 (block);
  2368. put_pixels_clamped2_c(block, dest, line_size);
  2369. }
  2370. static void ff_jref_idct2_add(uint8_t *dest, int line_size, int16_t *block)
  2371. {
  2372. ff_j_rev_dct2 (block);
  2373. add_pixels_clamped2_c(block, dest, line_size);
  2374. }
  2375. static void ff_jref_idct1_put(uint8_t *dest, int line_size, int16_t *block)
  2376. {
  2377. dest[0] = av_clip_uint8((block[0] + 4)>>3);
  2378. }
  2379. static void ff_jref_idct1_add(uint8_t *dest, int line_size, int16_t *block)
  2380. {
  2381. dest[0] = av_clip_uint8(dest[0] + ((block[0] + 4)>>3));
  2382. }
  2383. /* init static data */
  2384. av_cold void ff_dsputil_static_init(void)
  2385. {
  2386. int i;
  2387. for(i=0;i<512;i++) {
  2388. ff_squareTbl[i] = (i - 256) * (i - 256);
  2389. }
  2390. for(i=0; i<64; i++) ff_inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1;
  2391. }
  2392. int ff_check_alignment(void){
  2393. static int did_fail=0;
  2394. LOCAL_ALIGNED_16(int, aligned, [4]);
  2395. if((intptr_t)aligned & 15){
  2396. if(!did_fail){
  2397. #if HAVE_MMX || HAVE_ALTIVEC
  2398. av_log(NULL, AV_LOG_ERROR,
  2399. "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
  2400. "and may be very slow or crash. This is not a bug in libavcodec,\n"
  2401. "but in the compiler. You may try recompiling using gcc >= 4.2.\n"
  2402. "Do not report crashes to FFmpeg developers.\n");
  2403. #endif
  2404. did_fail=1;
  2405. }
  2406. return -1;
  2407. }
  2408. return 0;
  2409. }
  2410. av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
  2411. {
  2412. ff_check_alignment();
  2413. #if CONFIG_ENCODERS
  2414. if (avctx->bits_per_raw_sample == 10) {
  2415. c->fdct = ff_jpeg_fdct_islow_10;
  2416. c->fdct248 = ff_fdct248_islow_10;
  2417. } else {
  2418. if(avctx->dct_algo==FF_DCT_FASTINT) {
  2419. c->fdct = ff_fdct_ifast;
  2420. c->fdct248 = ff_fdct_ifast248;
  2421. }
  2422. else if(avctx->dct_algo==FF_DCT_FAAN) {
  2423. c->fdct = ff_faandct;
  2424. c->fdct248 = ff_faandct248;
  2425. }
  2426. else {
  2427. c->fdct = ff_jpeg_fdct_islow_8; //slow/accurate/default
  2428. c->fdct248 = ff_fdct248_islow_8;
  2429. }
  2430. }
  2431. #endif //CONFIG_ENCODERS
  2432. if(avctx->lowres==1){
  2433. c->idct_put= ff_jref_idct4_put;
  2434. c->idct_add= ff_jref_idct4_add;
  2435. c->idct = ff_j_rev_dct4;
  2436. c->idct_permutation_type= FF_NO_IDCT_PERM;
  2437. }else if(avctx->lowres==2){
  2438. c->idct_put= ff_jref_idct2_put;
  2439. c->idct_add= ff_jref_idct2_add;
  2440. c->idct = ff_j_rev_dct2;
  2441. c->idct_permutation_type= FF_NO_IDCT_PERM;
  2442. }else if(avctx->lowres==3){
  2443. c->idct_put= ff_jref_idct1_put;
  2444. c->idct_add= ff_jref_idct1_add;
  2445. c->idct = ff_j_rev_dct1;
  2446. c->idct_permutation_type= FF_NO_IDCT_PERM;
  2447. }else{
  2448. if (avctx->bits_per_raw_sample == 10) {
  2449. c->idct_put = ff_simple_idct_put_10;
  2450. c->idct_add = ff_simple_idct_add_10;
  2451. c->idct = ff_simple_idct_10;
  2452. c->idct_permutation_type = FF_NO_IDCT_PERM;
  2453. } else {
  2454. if(avctx->idct_algo==FF_IDCT_INT){
  2455. c->idct_put= jref_idct_put;
  2456. c->idct_add= jref_idct_add;
  2457. c->idct = ff_j_rev_dct;
  2458. c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
  2459. }else if(avctx->idct_algo==FF_IDCT_FAAN){
  2460. c->idct_put= ff_faanidct_put;
  2461. c->idct_add= ff_faanidct_add;
  2462. c->idct = ff_faanidct;
  2463. c->idct_permutation_type= FF_NO_IDCT_PERM;
  2464. }else{ //accurate/default
  2465. c->idct_put = ff_simple_idct_put_8;
  2466. c->idct_add = ff_simple_idct_add_8;
  2467. c->idct = ff_simple_idct_8;
  2468. c->idct_permutation_type= FF_NO_IDCT_PERM;
  2469. }
  2470. }
  2471. }
  2472. c->diff_pixels = diff_pixels_c;
  2473. c->put_pixels_clamped = put_pixels_clamped_c;
  2474. c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
  2475. c->add_pixels_clamped = add_pixels_clamped_c;
  2476. c->sum_abs_dctelem = sum_abs_dctelem_c;
  2477. c->gmc1 = gmc1_c;
  2478. c->gmc = ff_gmc_c;
  2479. c->pix_sum = pix_sum_c;
  2480. c->pix_norm1 = pix_norm1_c;
  2481. c->fill_block_tab[0] = fill_block16_c;
  2482. c->fill_block_tab[1] = fill_block8_c;
  2483. /* TODO [0] 16 [1] 8 */
  2484. c->pix_abs[0][0] = pix_abs16_c;
  2485. c->pix_abs[0][1] = pix_abs16_x2_c;
  2486. c->pix_abs[0][2] = pix_abs16_y2_c;
  2487. c->pix_abs[0][3] = pix_abs16_xy2_c;
  2488. c->pix_abs[1][0] = pix_abs8_c;
  2489. c->pix_abs[1][1] = pix_abs8_x2_c;
  2490. c->pix_abs[1][2] = pix_abs8_y2_c;
  2491. c->pix_abs[1][3] = pix_abs8_xy2_c;
  2492. c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
  2493. c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
  2494. c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
  2495. c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
  2496. c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
  2497. c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
  2498. c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
  2499. c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
  2500. c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
  2501. c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
  2502. c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
  2503. c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
  2504. c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
  2505. c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
  2506. c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
  2507. c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
  2508. c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
  2509. c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
  2510. #define dspfunc(PFX, IDX, NUM) \
  2511. c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
  2512. c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
  2513. c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
  2514. c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
  2515. c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
  2516. c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
  2517. c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
  2518. c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
  2519. c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
  2520. c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
  2521. c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
  2522. c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
  2523. c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
  2524. c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \
  2525. c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \
  2526. c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
  2527. dspfunc(put_qpel, 0, 16);
  2528. dspfunc(put_no_rnd_qpel, 0, 16);
  2529. dspfunc(avg_qpel, 0, 16);
  2530. /* dspfunc(avg_no_rnd_qpel, 0, 16); */
  2531. dspfunc(put_qpel, 1, 8);
  2532. dspfunc(put_no_rnd_qpel, 1, 8);
  2533. dspfunc(avg_qpel, 1, 8);
  2534. /* dspfunc(avg_no_rnd_qpel, 1, 8); */
  2535. #undef dspfunc
  2536. c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c;
  2537. c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
  2538. c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
  2539. c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
  2540. c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
  2541. c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
  2542. c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
  2543. c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
  2544. #define SET_CMP_FUNC(name) \
  2545. c->name[0]= name ## 16_c;\
  2546. c->name[1]= name ## 8x8_c;
  2547. SET_CMP_FUNC(hadamard8_diff)
  2548. c->hadamard8_diff[4]= hadamard8_intra16_c;
  2549. c->hadamard8_diff[5]= hadamard8_intra8x8_c;
  2550. SET_CMP_FUNC(dct_sad)
  2551. SET_CMP_FUNC(dct_max)
  2552. #if CONFIG_GPL
  2553. SET_CMP_FUNC(dct264_sad)
  2554. #endif
  2555. c->sad[0]= pix_abs16_c;
  2556. c->sad[1]= pix_abs8_c;
  2557. c->sse[0]= sse16_c;
  2558. c->sse[1]= sse8_c;
  2559. c->sse[2]= sse4_c;
  2560. SET_CMP_FUNC(quant_psnr)
  2561. SET_CMP_FUNC(rd)
  2562. SET_CMP_FUNC(bit)
  2563. c->vsad[0]= vsad16_c;
  2564. c->vsad[4]= vsad_intra16_c;
  2565. c->vsad[5]= vsad_intra8_c;
  2566. c->vsse[0]= vsse16_c;
  2567. c->vsse[4]= vsse_intra16_c;
  2568. c->vsse[5]= vsse_intra8_c;
  2569. c->nsse[0]= nsse16_c;
  2570. c->nsse[1]= nsse8_c;
  2571. #if CONFIG_SNOW_DECODER || CONFIG_SNOW_ENCODER
  2572. ff_dsputil_init_dwt(c);
  2573. #endif
  2574. c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
  2575. c->add_bytes= add_bytes_c;
  2576. c->diff_bytes= diff_bytes_c;
  2577. c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;
  2578. c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
  2579. c->add_hfyu_left_prediction = add_hfyu_left_prediction_c;
  2580. c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;
  2581. c->bswap_buf= bswap_buf;
  2582. c->bswap16_buf = bswap16_buf;
  2583. if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) {
  2584. c->h263_h_loop_filter= h263_h_loop_filter_c;
  2585. c->h263_v_loop_filter= h263_v_loop_filter_c;
  2586. }
  2587. c->try_8x8basis= try_8x8basis_c;
  2588. c->add_8x8basis= add_8x8basis_c;
  2589. c->vector_clipf = vector_clipf_c;
  2590. c->scalarproduct_int16 = scalarproduct_int16_c;
  2591. c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
  2592. c->apply_window_int16 = apply_window_int16_c;
  2593. c->vector_clip_int32 = vector_clip_int32_c;
  2594. c->shrink[0]= av_image_copy_plane;
  2595. c->shrink[1]= ff_shrink22;
  2596. c->shrink[2]= ff_shrink44;
  2597. c->shrink[3]= ff_shrink88;
  2598. c->add_pixels8 = add_pixels8_c;
  2599. #undef FUNC
  2600. #undef FUNCC
  2601. #define FUNC(f, depth) f ## _ ## depth
  2602. #define FUNCC(f, depth) f ## _ ## depth ## _c
  2603. c->draw_edges = FUNCC(draw_edges, 8);
  2604. c->clear_block = FUNCC(clear_block, 8);
  2605. c->clear_blocks = FUNCC(clear_blocks, 8);
  2606. #define BIT_DEPTH_FUNCS(depth) \
  2607. c->get_pixels = FUNCC(get_pixels, depth);
  2608. switch (avctx->bits_per_raw_sample) {
  2609. case 9:
  2610. case 10:
  2611. case 12:
  2612. case 14:
  2613. BIT_DEPTH_FUNCS(16);
  2614. break;
  2615. default:
  2616. if(avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
  2617. BIT_DEPTH_FUNCS(8);
  2618. }
  2619. break;
  2620. }
  2621. if (ARCH_ALPHA)
  2622. ff_dsputil_init_alpha(c, avctx);
  2623. if (ARCH_ARM)
  2624. ff_dsputil_init_arm(c, avctx);
  2625. if (ARCH_BFIN)
  2626. ff_dsputil_init_bfin(c, avctx);
  2627. if (ARCH_PPC)
  2628. ff_dsputil_init_ppc(c, avctx);
  2629. if (ARCH_SH4)
  2630. ff_dsputil_init_sh4(c, avctx);
  2631. if (HAVE_VIS)
  2632. ff_dsputil_init_vis(c, avctx);
  2633. if (ARCH_X86)
  2634. ff_dsputil_init_x86(c, avctx);
  2635. ff_init_scantable_permutation(c->idct_permutation,
  2636. c->idct_permutation_type);
  2637. }
  2638. av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
  2639. {
  2640. ff_dsputil_init(c, avctx);
  2641. }
  2642. av_cold void avpriv_dsputil_init(DSPContext *c, AVCodecContext *avctx)
  2643. {
  2644. ff_dsputil_init(c, avctx);
  2645. }