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.

1185 lines
39KB

  1. /*
  2. * DSP utils
  3. * Copyright (c) 2000, 2001 Fabrice Bellard
  4. * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file
  24. * DSP utils
  25. */
  26. #include "libavutil/attributes.h"
  27. #include "libavutil/imgutils.h"
  28. #include "libavutil/internal.h"
  29. #include "avcodec.h"
  30. #include "copy_block.h"
  31. #include "dct.h"
  32. #include "dsputil.h"
  33. #include "simple_idct.h"
  34. #include "faandct.h"
  35. #include "imgconvert.h"
  36. #include "mathops.h"
  37. #include "mpegvideo.h"
  38. #include "config.h"
  39. uint32_t ff_square_tab[512] = { 0, };
  40. #define BIT_DEPTH 16
  41. #include "dsputilenc_template.c"
  42. #undef BIT_DEPTH
  43. #define BIT_DEPTH 8
  44. #include "dsputilenc_template.c"
  45. static int pix_sum_c(uint8_t *pix, int line_size)
  46. {
  47. int s = 0, i, j;
  48. for (i = 0; i < 16; i++) {
  49. for (j = 0; j < 16; j += 8) {
  50. s += pix[0];
  51. s += pix[1];
  52. s += pix[2];
  53. s += pix[3];
  54. s += pix[4];
  55. s += pix[5];
  56. s += pix[6];
  57. s += pix[7];
  58. pix += 8;
  59. }
  60. pix += line_size - 16;
  61. }
  62. return s;
  63. }
  64. static int pix_norm1_c(uint8_t *pix, int line_size)
  65. {
  66. int s = 0, i, j;
  67. uint32_t *sq = ff_square_tab + 256;
  68. for (i = 0; i < 16; i++) {
  69. for (j = 0; j < 16; j += 8) {
  70. #if 0
  71. s += sq[pix[0]];
  72. s += sq[pix[1]];
  73. s += sq[pix[2]];
  74. s += sq[pix[3]];
  75. s += sq[pix[4]];
  76. s += sq[pix[5]];
  77. s += sq[pix[6]];
  78. s += sq[pix[7]];
  79. #else
  80. #if HAVE_FAST_64BIT
  81. register uint64_t x = *(uint64_t *) pix;
  82. s += sq[x & 0xff];
  83. s += sq[(x >> 8) & 0xff];
  84. s += sq[(x >> 16) & 0xff];
  85. s += sq[(x >> 24) & 0xff];
  86. s += sq[(x >> 32) & 0xff];
  87. s += sq[(x >> 40) & 0xff];
  88. s += sq[(x >> 48) & 0xff];
  89. s += sq[(x >> 56) & 0xff];
  90. #else
  91. register uint32_t x = *(uint32_t *) pix;
  92. s += sq[x & 0xff];
  93. s += sq[(x >> 8) & 0xff];
  94. s += sq[(x >> 16) & 0xff];
  95. s += sq[(x >> 24) & 0xff];
  96. x = *(uint32_t *) (pix + 4);
  97. s += sq[x & 0xff];
  98. s += sq[(x >> 8) & 0xff];
  99. s += sq[(x >> 16) & 0xff];
  100. s += sq[(x >> 24) & 0xff];
  101. #endif
  102. #endif
  103. pix += 8;
  104. }
  105. pix += line_size - 16;
  106. }
  107. return s;
  108. }
  109. static int sse4_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  110. int line_size, int h)
  111. {
  112. int s = 0, i;
  113. uint32_t *sq = ff_square_tab + 256;
  114. for (i = 0; i < h; i++) {
  115. s += sq[pix1[0] - pix2[0]];
  116. s += sq[pix1[1] - pix2[1]];
  117. s += sq[pix1[2] - pix2[2]];
  118. s += sq[pix1[3] - pix2[3]];
  119. pix1 += line_size;
  120. pix2 += line_size;
  121. }
  122. return s;
  123. }
  124. static int sse8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  125. int line_size, int h)
  126. {
  127. int s = 0, i;
  128. uint32_t *sq = ff_square_tab + 256;
  129. for (i = 0; i < h; i++) {
  130. s += sq[pix1[0] - pix2[0]];
  131. s += sq[pix1[1] - pix2[1]];
  132. s += sq[pix1[2] - pix2[2]];
  133. s += sq[pix1[3] - pix2[3]];
  134. s += sq[pix1[4] - pix2[4]];
  135. s += sq[pix1[5] - pix2[5]];
  136. s += sq[pix1[6] - pix2[6]];
  137. s += sq[pix1[7] - pix2[7]];
  138. pix1 += line_size;
  139. pix2 += line_size;
  140. }
  141. return s;
  142. }
  143. static int sse16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  144. int line_size, int h)
  145. {
  146. int s = 0, i;
  147. uint32_t *sq = ff_square_tab + 256;
  148. for (i = 0; i < h; i++) {
  149. s += sq[pix1[0] - pix2[0]];
  150. s += sq[pix1[1] - pix2[1]];
  151. s += sq[pix1[2] - pix2[2]];
  152. s += sq[pix1[3] - pix2[3]];
  153. s += sq[pix1[4] - pix2[4]];
  154. s += sq[pix1[5] - pix2[5]];
  155. s += sq[pix1[6] - pix2[6]];
  156. s += sq[pix1[7] - pix2[7]];
  157. s += sq[pix1[8] - pix2[8]];
  158. s += sq[pix1[9] - pix2[9]];
  159. s += sq[pix1[10] - pix2[10]];
  160. s += sq[pix1[11] - pix2[11]];
  161. s += sq[pix1[12] - pix2[12]];
  162. s += sq[pix1[13] - pix2[13]];
  163. s += sq[pix1[14] - pix2[14]];
  164. s += sq[pix1[15] - pix2[15]];
  165. pix1 += line_size;
  166. pix2 += line_size;
  167. }
  168. return s;
  169. }
  170. static void diff_pixels_c(int16_t *av_restrict block, const uint8_t *s1,
  171. const uint8_t *s2, int stride)
  172. {
  173. int i;
  174. /* read the pixels */
  175. for (i = 0; i < 8; i++) {
  176. block[0] = s1[0] - s2[0];
  177. block[1] = s1[1] - s2[1];
  178. block[2] = s1[2] - s2[2];
  179. block[3] = s1[3] - s2[3];
  180. block[4] = s1[4] - s2[4];
  181. block[5] = s1[5] - s2[5];
  182. block[6] = s1[6] - s2[6];
  183. block[7] = s1[7] - s2[7];
  184. s1 += stride;
  185. s2 += stride;
  186. block += 8;
  187. }
  188. }
  189. static int sum_abs_dctelem_c(int16_t *block)
  190. {
  191. int sum = 0, i;
  192. for (i = 0; i < 64; i++)
  193. sum += FFABS(block[i]);
  194. return sum;
  195. }
  196. #define avg2(a, b) ((a + b + 1) >> 1)
  197. #define avg4(a, b, c, d) ((a + b + c + d + 2) >> 2)
  198. static inline int pix_abs16_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  199. int line_size, int h)
  200. {
  201. int s = 0, i;
  202. for (i = 0; i < h; i++) {
  203. s += abs(pix1[0] - pix2[0]);
  204. s += abs(pix1[1] - pix2[1]);
  205. s += abs(pix1[2] - pix2[2]);
  206. s += abs(pix1[3] - pix2[3]);
  207. s += abs(pix1[4] - pix2[4]);
  208. s += abs(pix1[5] - pix2[5]);
  209. s += abs(pix1[6] - pix2[6]);
  210. s += abs(pix1[7] - pix2[7]);
  211. s += abs(pix1[8] - pix2[8]);
  212. s += abs(pix1[9] - pix2[9]);
  213. s += abs(pix1[10] - pix2[10]);
  214. s += abs(pix1[11] - pix2[11]);
  215. s += abs(pix1[12] - pix2[12]);
  216. s += abs(pix1[13] - pix2[13]);
  217. s += abs(pix1[14] - pix2[14]);
  218. s += abs(pix1[15] - pix2[15]);
  219. pix1 += line_size;
  220. pix2 += line_size;
  221. }
  222. return s;
  223. }
  224. static int pix_abs16_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  225. int line_size, int h)
  226. {
  227. int s = 0, i;
  228. for (i = 0; i < h; i++) {
  229. s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
  230. s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
  231. s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
  232. s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
  233. s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
  234. s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
  235. s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
  236. s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
  237. s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
  238. s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
  239. s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
  240. s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
  241. s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
  242. s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
  243. s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
  244. s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
  245. pix1 += line_size;
  246. pix2 += line_size;
  247. }
  248. return s;
  249. }
  250. static int pix_abs16_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  251. int line_size, int h)
  252. {
  253. int s = 0, i;
  254. uint8_t *pix3 = pix2 + line_size;
  255. for (i = 0; i < h; i++) {
  256. s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
  257. s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
  258. s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
  259. s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
  260. s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
  261. s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
  262. s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
  263. s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
  264. s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
  265. s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
  266. s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
  267. s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
  268. s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
  269. s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
  270. s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
  271. s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
  272. pix1 += line_size;
  273. pix2 += line_size;
  274. pix3 += line_size;
  275. }
  276. return s;
  277. }
  278. static int pix_abs16_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  279. int line_size, int h)
  280. {
  281. int s = 0, i;
  282. uint8_t *pix3 = pix2 + line_size;
  283. for (i = 0; i < h; i++) {
  284. s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
  285. s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
  286. s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
  287. s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
  288. s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
  289. s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
  290. s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
  291. s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
  292. s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
  293. s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
  294. s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
  295. s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
  296. s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
  297. s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
  298. s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
  299. s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
  300. pix1 += line_size;
  301. pix2 += line_size;
  302. pix3 += line_size;
  303. }
  304. return s;
  305. }
  306. static inline int pix_abs8_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  307. int line_size, int h)
  308. {
  309. int s = 0, i;
  310. for (i = 0; i < h; i++) {
  311. s += abs(pix1[0] - pix2[0]);
  312. s += abs(pix1[1] - pix2[1]);
  313. s += abs(pix1[2] - pix2[2]);
  314. s += abs(pix1[3] - pix2[3]);
  315. s += abs(pix1[4] - pix2[4]);
  316. s += abs(pix1[5] - pix2[5]);
  317. s += abs(pix1[6] - pix2[6]);
  318. s += abs(pix1[7] - pix2[7]);
  319. pix1 += line_size;
  320. pix2 += line_size;
  321. }
  322. return s;
  323. }
  324. static int pix_abs8_x2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  325. int line_size, int h)
  326. {
  327. int s = 0, i;
  328. for (i = 0; i < h; i++) {
  329. s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
  330. s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
  331. s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
  332. s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
  333. s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
  334. s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
  335. s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
  336. s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
  337. pix1 += line_size;
  338. pix2 += line_size;
  339. }
  340. return s;
  341. }
  342. static int pix_abs8_y2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  343. int line_size, int h)
  344. {
  345. int s = 0, i;
  346. uint8_t *pix3 = pix2 + line_size;
  347. for (i = 0; i < h; i++) {
  348. s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
  349. s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
  350. s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
  351. s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
  352. s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
  353. s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
  354. s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
  355. s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
  356. pix1 += line_size;
  357. pix2 += line_size;
  358. pix3 += line_size;
  359. }
  360. return s;
  361. }
  362. static int pix_abs8_xy2_c(MpegEncContext *v, uint8_t *pix1, uint8_t *pix2,
  363. int line_size, int h)
  364. {
  365. int s = 0, i;
  366. uint8_t *pix3 = pix2 + line_size;
  367. for (i = 0; i < h; i++) {
  368. s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
  369. s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
  370. s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
  371. s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
  372. s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
  373. s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
  374. s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
  375. s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
  376. pix1 += line_size;
  377. pix2 += line_size;
  378. pix3 += line_size;
  379. }
  380. return s;
  381. }
  382. static int nsse16_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, int stride, int h)
  383. {
  384. int score1 = 0, score2 = 0, x, y;
  385. for (y = 0; y < h; y++) {
  386. for (x = 0; x < 16; x++)
  387. score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
  388. if (y + 1 < h) {
  389. for (x = 0; x < 15; x++)
  390. score2 += FFABS(s1[x] - s1[x + stride] -
  391. s1[x + 1] + s1[x + stride + 1]) -
  392. FFABS(s2[x] - s2[x + stride] -
  393. s2[x + 1] + s2[x + stride + 1]);
  394. }
  395. s1 += stride;
  396. s2 += stride;
  397. }
  398. if (c)
  399. return score1 + FFABS(score2) * c->avctx->nsse_weight;
  400. else
  401. return score1 + FFABS(score2) * 8;
  402. }
  403. static int nsse8_c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, int stride, int h)
  404. {
  405. int score1 = 0, score2 = 0, x, y;
  406. for (y = 0; y < h; y++) {
  407. for (x = 0; x < 8; x++)
  408. score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
  409. if (y + 1 < h) {
  410. for (x = 0; x < 7; x++)
  411. score2 += FFABS(s1[x] - s1[x + stride] -
  412. s1[x + 1] + s1[x + stride + 1]) -
  413. FFABS(s2[x] - s2[x + stride] -
  414. s2[x + 1] + s2[x + stride + 1]);
  415. }
  416. s1 += stride;
  417. s2 += stride;
  418. }
  419. if (c)
  420. return score1 + FFABS(score2) * c->avctx->nsse_weight;
  421. else
  422. return score1 + FFABS(score2) * 8;
  423. }
  424. static int zero_cmp(MpegEncContext *s, uint8_t *a, uint8_t *b,
  425. int stride, int h)
  426. {
  427. return 0;
  428. }
  429. void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type)
  430. {
  431. int i;
  432. memset(cmp, 0, sizeof(void *) * 6);
  433. for (i = 0; i < 6; i++) {
  434. switch (type & 0xFF) {
  435. case FF_CMP_SAD:
  436. cmp[i] = c->sad[i];
  437. break;
  438. case FF_CMP_SATD:
  439. cmp[i] = c->hadamard8_diff[i];
  440. break;
  441. case FF_CMP_SSE:
  442. cmp[i] = c->sse[i];
  443. break;
  444. case FF_CMP_DCT:
  445. cmp[i] = c->dct_sad[i];
  446. break;
  447. case FF_CMP_DCT264:
  448. cmp[i] = c->dct264_sad[i];
  449. break;
  450. case FF_CMP_DCTMAX:
  451. cmp[i] = c->dct_max[i];
  452. break;
  453. case FF_CMP_PSNR:
  454. cmp[i] = c->quant_psnr[i];
  455. break;
  456. case FF_CMP_BIT:
  457. cmp[i] = c->bit[i];
  458. break;
  459. case FF_CMP_RD:
  460. cmp[i] = c->rd[i];
  461. break;
  462. case FF_CMP_VSAD:
  463. cmp[i] = c->vsad[i];
  464. break;
  465. case FF_CMP_VSSE:
  466. cmp[i] = c->vsse[i];
  467. break;
  468. case FF_CMP_ZERO:
  469. cmp[i] = zero_cmp;
  470. break;
  471. case FF_CMP_NSSE:
  472. cmp[i] = c->nsse[i];
  473. break;
  474. #if CONFIG_DWT
  475. case FF_CMP_W53:
  476. cmp[i]= c->w53[i];
  477. break;
  478. case FF_CMP_W97:
  479. cmp[i]= c->w97[i];
  480. break;
  481. #endif
  482. default:
  483. av_log(NULL, AV_LOG_ERROR,
  484. "internal error in cmp function selection\n");
  485. }
  486. }
  487. }
  488. #define BUTTERFLY2(o1, o2, i1, i2) \
  489. o1 = (i1) + (i2); \
  490. o2 = (i1) - (i2);
  491. #define BUTTERFLY1(x, y) \
  492. { \
  493. int a, b; \
  494. a = x; \
  495. b = y; \
  496. x = a + b; \
  497. y = a - b; \
  498. }
  499. #define BUTTERFLYA(x, y) (FFABS((x) + (y)) + FFABS((x) - (y)))
  500. static int hadamard8_diff8x8_c(MpegEncContext *s, uint8_t *dst,
  501. uint8_t *src, int stride, int h)
  502. {
  503. int i, temp[64], sum = 0;
  504. av_assert2(h == 8);
  505. for (i = 0; i < 8; i++) {
  506. // FIXME: try pointer walks
  507. BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
  508. src[stride * i + 0] - dst[stride * i + 0],
  509. src[stride * i + 1] - dst[stride * i + 1]);
  510. BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
  511. src[stride * i + 2] - dst[stride * i + 2],
  512. src[stride * i + 3] - dst[stride * i + 3]);
  513. BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
  514. src[stride * i + 4] - dst[stride * i + 4],
  515. src[stride * i + 5] - dst[stride * i + 5]);
  516. BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
  517. src[stride * i + 6] - dst[stride * i + 6],
  518. src[stride * i + 7] - dst[stride * i + 7]);
  519. BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
  520. BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
  521. BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
  522. BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
  523. BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
  524. BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
  525. BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
  526. BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
  527. }
  528. for (i = 0; i < 8; i++) {
  529. BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
  530. BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
  531. BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
  532. BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
  533. BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
  534. BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
  535. BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
  536. BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
  537. sum += BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i]) +
  538. BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i]) +
  539. BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i]) +
  540. BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
  541. }
  542. return sum;
  543. }
  544. static int hadamard8_intra8x8_c(MpegEncContext *s, uint8_t *src,
  545. uint8_t *dummy, int stride, int h)
  546. {
  547. int i, temp[64], sum = 0;
  548. av_assert2(h == 8);
  549. for (i = 0; i < 8; i++) {
  550. // FIXME: try pointer walks
  551. BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
  552. src[stride * i + 0], src[stride * i + 1]);
  553. BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
  554. src[stride * i + 2], src[stride * i + 3]);
  555. BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
  556. src[stride * i + 4], src[stride * i + 5]);
  557. BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
  558. src[stride * i + 6], src[stride * i + 7]);
  559. BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
  560. BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
  561. BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
  562. BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
  563. BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
  564. BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
  565. BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
  566. BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
  567. }
  568. for (i = 0; i < 8; i++) {
  569. BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
  570. BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
  571. BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
  572. BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
  573. BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
  574. BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
  575. BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
  576. BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
  577. sum +=
  578. BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i])
  579. + BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i])
  580. + BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i])
  581. + BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
  582. }
  583. sum -= FFABS(temp[8 * 0] + temp[8 * 4]); // -mean
  584. return sum;
  585. }
  586. static int dct_sad8x8_c(MpegEncContext *s, uint8_t *src1,
  587. uint8_t *src2, int stride, int h)
  588. {
  589. LOCAL_ALIGNED_16(int16_t, temp, [64]);
  590. av_assert2(h == 8);
  591. s->dsp.diff_pixels(temp, src1, src2, stride);
  592. s->dsp.fdct(temp);
  593. return s->dsp.sum_abs_dctelem(temp);
  594. }
  595. #if CONFIG_GPL
  596. #define DCT8_1D \
  597. { \
  598. const int s07 = SRC(0) + SRC(7); \
  599. const int s16 = SRC(1) + SRC(6); \
  600. const int s25 = SRC(2) + SRC(5); \
  601. const int s34 = SRC(3) + SRC(4); \
  602. const int a0 = s07 + s34; \
  603. const int a1 = s16 + s25; \
  604. const int a2 = s07 - s34; \
  605. const int a3 = s16 - s25; \
  606. const int d07 = SRC(0) - SRC(7); \
  607. const int d16 = SRC(1) - SRC(6); \
  608. const int d25 = SRC(2) - SRC(5); \
  609. const int d34 = SRC(3) - SRC(4); \
  610. const int a4 = d16 + d25 + (d07 + (d07 >> 1)); \
  611. const int a5 = d07 - d34 - (d25 + (d25 >> 1)); \
  612. const int a6 = d07 + d34 - (d16 + (d16 >> 1)); \
  613. const int a7 = d16 - d25 + (d34 + (d34 >> 1)); \
  614. DST(0, a0 + a1); \
  615. DST(1, a4 + (a7 >> 2)); \
  616. DST(2, a2 + (a3 >> 1)); \
  617. DST(3, a5 + (a6 >> 2)); \
  618. DST(4, a0 - a1); \
  619. DST(5, a6 - (a5 >> 2)); \
  620. DST(6, (a2 >> 1) - a3); \
  621. DST(7, (a4 >> 2) - a7); \
  622. }
  623. static int dct264_sad8x8_c(MpegEncContext *s, uint8_t *src1,
  624. uint8_t *src2, int stride, int h)
  625. {
  626. int16_t dct[8][8];
  627. int i, sum = 0;
  628. s->dsp.diff_pixels(dct[0], src1, src2, stride);
  629. #define SRC(x) dct[i][x]
  630. #define DST(x, v) dct[i][x] = v
  631. for (i = 0; i < 8; i++)
  632. DCT8_1D
  633. #undef SRC
  634. #undef DST
  635. #define SRC(x) dct[x][i]
  636. #define DST(x, v) sum += FFABS(v)
  637. for (i = 0; i < 8; i++)
  638. DCT8_1D
  639. #undef SRC
  640. #undef DST
  641. return sum;
  642. }
  643. #endif
  644. static int dct_max8x8_c(MpegEncContext *s, uint8_t *src1,
  645. uint8_t *src2, int stride, int h)
  646. {
  647. LOCAL_ALIGNED_16(int16_t, temp, [64]);
  648. int sum = 0, i;
  649. av_assert2(h == 8);
  650. s->dsp.diff_pixels(temp, src1, src2, stride);
  651. s->dsp.fdct(temp);
  652. for (i = 0; i < 64; i++)
  653. sum = FFMAX(sum, FFABS(temp[i]));
  654. return sum;
  655. }
  656. static int quant_psnr8x8_c(MpegEncContext *s, uint8_t *src1,
  657. uint8_t *src2, int stride, int h)
  658. {
  659. LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
  660. int16_t *const bak = temp + 64;
  661. int sum = 0, i;
  662. av_assert2(h == 8);
  663. s->mb_intra = 0;
  664. s->dsp.diff_pixels(temp, src1, src2, stride);
  665. memcpy(bak, temp, 64 * sizeof(int16_t));
  666. s->block_last_index[0 /* FIXME */] =
  667. s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
  668. s->dct_unquantize_inter(s, temp, 0, s->qscale);
  669. ff_simple_idct_8(temp); // FIXME
  670. for (i = 0; i < 64; i++)
  671. sum += (temp[i] - bak[i]) * (temp[i] - bak[i]);
  672. return sum;
  673. }
  674. static int rd8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
  675. int stride, int h)
  676. {
  677. const uint8_t *scantable = s->intra_scantable.permutated;
  678. LOCAL_ALIGNED_16(int16_t, temp, [64]);
  679. LOCAL_ALIGNED_16(uint8_t, lsrc1, [64]);
  680. LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]);
  681. int i, last, run, bits, level, distortion, start_i;
  682. const int esc_length = s->ac_esc_length;
  683. uint8_t *length, *last_length;
  684. av_assert2(h == 8);
  685. copy_block8(lsrc1, src1, 8, stride, 8);
  686. copy_block8(lsrc2, src2, 8, stride, 8);
  687. s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8);
  688. s->block_last_index[0 /* FIXME */] =
  689. last =
  690. s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
  691. bits = 0;
  692. if (s->mb_intra) {
  693. start_i = 1;
  694. length = s->intra_ac_vlc_length;
  695. last_length = s->intra_ac_vlc_last_length;
  696. bits += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
  697. } else {
  698. start_i = 0;
  699. length = s->inter_ac_vlc_length;
  700. last_length = s->inter_ac_vlc_last_length;
  701. }
  702. if (last >= start_i) {
  703. run = 0;
  704. for (i = start_i; i < last; i++) {
  705. int j = scantable[i];
  706. level = temp[j];
  707. if (level) {
  708. level += 64;
  709. if ((level & (~127)) == 0)
  710. bits += length[UNI_AC_ENC_INDEX(run, level)];
  711. else
  712. bits += esc_length;
  713. run = 0;
  714. } else
  715. run++;
  716. }
  717. i = scantable[last];
  718. level = temp[i] + 64;
  719. av_assert2(level - 64);
  720. if ((level & (~127)) == 0) {
  721. bits += last_length[UNI_AC_ENC_INDEX(run, level)];
  722. } else
  723. bits += esc_length;
  724. }
  725. if (last >= 0) {
  726. if (s->mb_intra)
  727. s->dct_unquantize_intra(s, temp, 0, s->qscale);
  728. else
  729. s->dct_unquantize_inter(s, temp, 0, s->qscale);
  730. }
  731. s->idsp.idct_add(lsrc2, 8, temp);
  732. distortion = s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
  733. return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7);
  734. }
  735. static int bit8x8_c(MpegEncContext *s, uint8_t *src1, uint8_t *src2,
  736. int stride, int h)
  737. {
  738. const uint8_t *scantable = s->intra_scantable.permutated;
  739. LOCAL_ALIGNED_16(int16_t, temp, [64]);
  740. int i, last, run, bits, level, start_i;
  741. const int esc_length = s->ac_esc_length;
  742. uint8_t *length, *last_length;
  743. av_assert2(h == 8);
  744. s->dsp.diff_pixels(temp, src1, src2, stride);
  745. s->block_last_index[0 /* FIXME */] =
  746. last =
  747. s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
  748. bits = 0;
  749. if (s->mb_intra) {
  750. start_i = 1;
  751. length = s->intra_ac_vlc_length;
  752. last_length = s->intra_ac_vlc_last_length;
  753. bits += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
  754. } else {
  755. start_i = 0;
  756. length = s->inter_ac_vlc_length;
  757. last_length = s->inter_ac_vlc_last_length;
  758. }
  759. if (last >= start_i) {
  760. run = 0;
  761. for (i = start_i; i < last; i++) {
  762. int j = scantable[i];
  763. level = temp[j];
  764. if (level) {
  765. level += 64;
  766. if ((level & (~127)) == 0)
  767. bits += length[UNI_AC_ENC_INDEX(run, level)];
  768. else
  769. bits += esc_length;
  770. run = 0;
  771. } else
  772. run++;
  773. }
  774. i = scantable[last];
  775. level = temp[i] + 64;
  776. av_assert2(level - 64);
  777. if ((level & (~127)) == 0)
  778. bits += last_length[UNI_AC_ENC_INDEX(run, level)];
  779. else
  780. bits += esc_length;
  781. }
  782. return bits;
  783. }
  784. #define VSAD_INTRA(size) \
  785. static int vsad_intra ## size ## _c(MpegEncContext *c, \
  786. uint8_t *s, uint8_t *dummy, \
  787. int stride, int h) \
  788. { \
  789. int score = 0, x, y; \
  790. \
  791. for (y = 1; y < h; y++) { \
  792. for (x = 0; x < size; x += 4) { \
  793. score += FFABS(s[x] - s[x + stride]) + \
  794. FFABS(s[x + 1] - s[x + stride + 1]) + \
  795. FFABS(s[x + 2] - s[x + 2 + stride]) + \
  796. FFABS(s[x + 3] - s[x + 3 + stride]); \
  797. } \
  798. s += stride; \
  799. } \
  800. \
  801. return score; \
  802. }
  803. VSAD_INTRA(8)
  804. VSAD_INTRA(16)
  805. #define VSAD(size) \
  806. static int vsad ## size ## _c(MpegEncContext *c, \
  807. uint8_t *s1, uint8_t *s2, \
  808. int stride, int h) \
  809. { \
  810. int score = 0, x, y; \
  811. \
  812. for (y = 1; y < h; y++) { \
  813. for (x = 0; x < size; x++) \
  814. score += FFABS(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]); \
  815. s1 += stride; \
  816. s2 += stride; \
  817. } \
  818. \
  819. return score; \
  820. }
  821. VSAD(8)
  822. VSAD(16)
  823. #define SQ(a) ((a) * (a))
  824. #define VSSE_INTRA(size) \
  825. static int vsse_intra ## size ## _c(MpegEncContext *c, \
  826. uint8_t *s, uint8_t *dummy, \
  827. int stride, int h) \
  828. { \
  829. int score = 0, x, y; \
  830. \
  831. for (y = 1; y < h; y++) { \
  832. for (x = 0; x < size; x += 4) { \
  833. score += SQ(s[x] - s[x + stride]) + \
  834. SQ(s[x + 1] - s[x + stride + 1]) + \
  835. SQ(s[x + 2] - s[x + stride + 2]) + \
  836. SQ(s[x + 3] - s[x + stride + 3]); \
  837. } \
  838. s += stride; \
  839. } \
  840. \
  841. return score; \
  842. }
  843. VSSE_INTRA(8)
  844. VSSE_INTRA(16)
  845. #define VSSE(size) \
  846. static int vsse ## size ## _c(MpegEncContext *c, uint8_t *s1, uint8_t *s2, \
  847. int stride, int h) \
  848. { \
  849. int score = 0, x, y; \
  850. \
  851. for (y = 1; y < h; y++) { \
  852. for (x = 0; x < size; x++) \
  853. score += SQ(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]); \
  854. s1 += stride; \
  855. s2 += stride; \
  856. } \
  857. \
  858. return score; \
  859. }
  860. VSSE(8)
  861. VSSE(16)
  862. #define WRAPPER8_16_SQ(name8, name16) \
  863. static int name16(MpegEncContext *s, uint8_t *dst, uint8_t *src, \
  864. int stride, int h) \
  865. { \
  866. int score = 0; \
  867. \
  868. score += name8(s, dst, src, stride, 8); \
  869. score += name8(s, dst + 8, src + 8, stride, 8); \
  870. if (h == 16) { \
  871. dst += 8 * stride; \
  872. src += 8 * stride; \
  873. score += name8(s, dst, src, stride, 8); \
  874. score += name8(s, dst + 8, src + 8, stride, 8); \
  875. } \
  876. return score; \
  877. }
  878. WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
  879. WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
  880. WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
  881. #if CONFIG_GPL
  882. WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
  883. #endif
  884. WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c)
  885. WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
  886. WRAPPER8_16_SQ(rd8x8_c, rd16_c)
  887. WRAPPER8_16_SQ(bit8x8_c, bit16_c)
  888. /* draw the edges of width 'w' of an image of size width, height */
  889. // FIXME: Check that this is OK for MPEG-4 interlaced.
  890. static void draw_edges_8_c(uint8_t *buf, int wrap, int width, int height,
  891. int w, int h, int sides)
  892. {
  893. uint8_t *ptr = buf, *last_line;
  894. int i;
  895. /* left and right */
  896. for (i = 0; i < height; i++) {
  897. memset(ptr - w, ptr[0], w);
  898. memset(ptr + width, ptr[width - 1], w);
  899. ptr += wrap;
  900. }
  901. /* top and bottom + corners */
  902. buf -= w;
  903. last_line = buf + (height - 1) * wrap;
  904. if (sides & EDGE_TOP)
  905. for (i = 0; i < h; i++)
  906. // top
  907. memcpy(buf - (i + 1) * wrap, buf, width + w + w);
  908. if (sides & EDGE_BOTTOM)
  909. for (i = 0; i < h; i++)
  910. // bottom
  911. memcpy(last_line + (i + 1) * wrap, last_line, width + w + w);
  912. }
  913. /* init static data */
  914. av_cold void ff_dsputil_static_init(void)
  915. {
  916. int i;
  917. for (i = 0; i < 512; i++)
  918. ff_square_tab[i] = (i - 256) * (i - 256);
  919. }
  920. int ff_check_alignment(void)
  921. {
  922. static int did_fail = 0;
  923. LOCAL_ALIGNED_16(int, aligned, [4]);
  924. if ((intptr_t)aligned & 15) {
  925. if (!did_fail) {
  926. #if HAVE_MMX || HAVE_ALTIVEC
  927. av_log(NULL, AV_LOG_ERROR,
  928. "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
  929. "and may be very slow or crash. This is not a bug in libavcodec,\n"
  930. "but in the compiler. You may try recompiling using gcc >= 4.2.\n"
  931. "Do not report crashes to FFmpeg developers.\n");
  932. #endif
  933. did_fail=1;
  934. }
  935. return -1;
  936. }
  937. return 0;
  938. }
  939. av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
  940. {
  941. const unsigned high_bit_depth = avctx->bits_per_raw_sample > 8;
  942. ff_check_alignment();
  943. #if CONFIG_ENCODERS
  944. if (avctx->bits_per_raw_sample == 10) {
  945. c->fdct = ff_jpeg_fdct_islow_10;
  946. c->fdct248 = ff_fdct248_islow_10;
  947. } else {
  948. if (avctx->dct_algo == FF_DCT_FASTINT) {
  949. c->fdct = ff_fdct_ifast;
  950. c->fdct248 = ff_fdct_ifast248;
  951. } else if (avctx->dct_algo == FF_DCT_FAAN) {
  952. c->fdct = ff_faandct;
  953. c->fdct248 = ff_faandct248;
  954. } else {
  955. c->fdct = ff_jpeg_fdct_islow_8; // slow/accurate/default
  956. c->fdct248 = ff_fdct248_islow_8;
  957. }
  958. }
  959. #endif /* CONFIG_ENCODERS */
  960. c->diff_pixels = diff_pixels_c;
  961. c->sum_abs_dctelem = sum_abs_dctelem_c;
  962. c->pix_sum = pix_sum_c;
  963. c->pix_norm1 = pix_norm1_c;
  964. /* TODO [0] 16 [1] 8 */
  965. c->pix_abs[0][0] = pix_abs16_c;
  966. c->pix_abs[0][1] = pix_abs16_x2_c;
  967. c->pix_abs[0][2] = pix_abs16_y2_c;
  968. c->pix_abs[0][3] = pix_abs16_xy2_c;
  969. c->pix_abs[1][0] = pix_abs8_c;
  970. c->pix_abs[1][1] = pix_abs8_x2_c;
  971. c->pix_abs[1][2] = pix_abs8_y2_c;
  972. c->pix_abs[1][3] = pix_abs8_xy2_c;
  973. #define SET_CMP_FUNC(name) \
  974. c->name[0] = name ## 16_c; \
  975. c->name[1] = name ## 8x8_c;
  976. SET_CMP_FUNC(hadamard8_diff)
  977. c->hadamard8_diff[4] = hadamard8_intra16_c;
  978. c->hadamard8_diff[5] = hadamard8_intra8x8_c;
  979. SET_CMP_FUNC(dct_sad)
  980. SET_CMP_FUNC(dct_max)
  981. #if CONFIG_GPL
  982. SET_CMP_FUNC(dct264_sad)
  983. #endif
  984. c->sad[0] = pix_abs16_c;
  985. c->sad[1] = pix_abs8_c;
  986. c->sse[0] = sse16_c;
  987. c->sse[1] = sse8_c;
  988. c->sse[2] = sse4_c;
  989. SET_CMP_FUNC(quant_psnr)
  990. SET_CMP_FUNC(rd)
  991. SET_CMP_FUNC(bit)
  992. c->vsad[0] = vsad16_c;
  993. c->vsad[1] = vsad8_c;
  994. c->vsad[4] = vsad_intra16_c;
  995. c->vsad[5] = vsad_intra8_c;
  996. c->vsse[0] = vsse16_c;
  997. c->vsse[1] = vsse8_c;
  998. c->vsse[4] = vsse_intra16_c;
  999. c->vsse[5] = vsse_intra8_c;
  1000. c->nsse[0] = nsse16_c;
  1001. c->nsse[1] = nsse8_c;
  1002. #if CONFIG_SNOW_DECODER || CONFIG_SNOW_ENCODER
  1003. ff_dsputil_init_dwt(c);
  1004. #endif
  1005. c->shrink[0] = av_image_copy_plane;
  1006. c->shrink[1] = ff_shrink22;
  1007. c->shrink[2] = ff_shrink44;
  1008. c->shrink[3] = ff_shrink88;
  1009. c->draw_edges = draw_edges_8_c;
  1010. switch (avctx->bits_per_raw_sample) {
  1011. case 9:
  1012. case 10:
  1013. case 12:
  1014. case 14:
  1015. c->get_pixels = get_pixels_16_c;
  1016. break;
  1017. default:
  1018. if (avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
  1019. c->get_pixels = get_pixels_8_c;
  1020. }
  1021. break;
  1022. }
  1023. if (ARCH_ALPHA)
  1024. ff_dsputil_init_alpha(c, avctx);
  1025. if (ARCH_ARM)
  1026. ff_dsputil_init_arm(c, avctx, high_bit_depth);
  1027. if (ARCH_PPC)
  1028. ff_dsputil_init_ppc(c, avctx, high_bit_depth);
  1029. if (ARCH_X86)
  1030. ff_dsputil_init_x86(c, avctx, high_bit_depth);
  1031. }
  1032. av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
  1033. {
  1034. ff_dsputil_init(c, avctx);
  1035. }
  1036. av_cold void avpriv_dsputil_init(DSPContext *c, AVCodecContext *avctx)
  1037. {
  1038. ff_dsputil_init(c, avctx);
  1039. }