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.

518 lines
20KB

  1. /*
  2. * Copyright (c) 2016 Martin Storsjo
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #include <string.h>
  21. #include "libavcodec/avcodec.h"
  22. #include "libavcodec/vp8dsp.h"
  23. #include "libavutil/common.h"
  24. #include "libavutil/intreadwrite.h"
  25. #include "checkasm.h"
  26. #define PIXEL_STRIDE 16
  27. #define randomize_buffers(src, dst, stride, coef) \
  28. do { \
  29. int x, y; \
  30. for (y = 0; y < 4; y++) { \
  31. AV_WN32A((src) + y * (stride), rnd()); \
  32. AV_WN32A((dst) + y * (stride), rnd()); \
  33. for (x = 0; x < 4; x++) \
  34. (coef)[y * 4 + x] = (src)[y * (stride) + x] - \
  35. (dst)[y * (stride) + x]; \
  36. } \
  37. } while (0)
  38. static void dct4x4(int16_t *coef)
  39. {
  40. int i;
  41. for (i = 0; i < 4; i++) {
  42. const int a1 = (coef[i*4 + 0] + coef[i*4 + 3]) * 8;
  43. const int b1 = (coef[i*4 + 1] + coef[i*4 + 2]) * 8;
  44. const int c1 = (coef[i*4 + 1] - coef[i*4 + 2]) * 8;
  45. const int d1 = (coef[i*4 + 0] - coef[i*4 + 3]) * 8;
  46. coef[i*4 + 0] = a1 + b1;
  47. coef[i*4 + 1] = (c1 * 2217 + d1 * 5352 + 14500) >> 12;
  48. coef[i*4 + 2] = a1 - b1;
  49. coef[i*4 + 3] = (d1 * 2217 - c1 * 5352 + 7500) >> 12;
  50. }
  51. for (i = 0; i < 4; i++) {
  52. const int a1 = coef[i + 0*4] + coef[i + 3*4];
  53. const int b1 = coef[i + 1*4] + coef[i + 2*4];
  54. const int c1 = coef[i + 1*4] - coef[i + 2*4];
  55. const int d1 = coef[i + 0*4] - coef[i + 3*4];
  56. coef[i + 0*4] = (a1 + b1 + 7) >> 4;
  57. coef[i + 1*4] = ((c1 * 2217 + d1 * 5352 + 12000) >> 16) + !!d1;
  58. coef[i + 2*4] = (a1 - b1 + 7) >> 4;
  59. coef[i + 3*4] = (d1 * 2217 - c1 * 5352 + 51000) >> 16;
  60. }
  61. }
  62. static void wht4x4(int16_t *coef)
  63. {
  64. int i;
  65. for (i = 0; i < 4; i++) {
  66. int a1 = coef[0 * 4 + i];
  67. int b1 = coef[1 * 4 + i];
  68. int c1 = coef[2 * 4 + i];
  69. int d1 = coef[3 * 4 + i];
  70. int e1;
  71. a1 += b1;
  72. d1 -= c1;
  73. e1 = (a1 - d1) >> 1;
  74. b1 = e1 - b1;
  75. c1 = e1 - c1;
  76. a1 -= c1;
  77. d1 += b1;
  78. coef[0 * 4 + i] = a1;
  79. coef[1 * 4 + i] = c1;
  80. coef[2 * 4 + i] = d1;
  81. coef[3 * 4 + i] = b1;
  82. }
  83. for (i = 0; i < 4; i++) {
  84. int a1 = coef[i * 4 + 0];
  85. int b1 = coef[i * 4 + 1];
  86. int c1 = coef[i * 4 + 2];
  87. int d1 = coef[i * 4 + 3];
  88. int e1;
  89. a1 += b1;
  90. d1 -= c1;
  91. e1 = (a1 - d1) >> 1;
  92. b1 = e1 - b1;
  93. c1 = e1 - c1;
  94. a1 -= c1;
  95. d1 += b1;
  96. coef[i * 4 + 0] = a1 * 2;
  97. coef[i * 4 + 1] = c1 * 2;
  98. coef[i * 4 + 2] = d1 * 2;
  99. coef[i * 4 + 3] = b1 * 2;
  100. }
  101. }
  102. static void check_idct(void)
  103. {
  104. LOCAL_ALIGNED_16(uint8_t, src, [4 * 4]);
  105. LOCAL_ALIGNED_16(uint8_t, dst, [4 * 4]);
  106. LOCAL_ALIGNED_16(uint8_t, dst0, [4 * 4]);
  107. LOCAL_ALIGNED_16(uint8_t, dst1, [4 * 4]);
  108. LOCAL_ALIGNED_16(int16_t, coef, [4 * 4]);
  109. LOCAL_ALIGNED_16(int16_t, subcoef0, [4 * 4]);
  110. LOCAL_ALIGNED_16(int16_t, subcoef1, [4 * 4]);
  111. VP8DSPContext d;
  112. int dc;
  113. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *block, ptrdiff_t stride);
  114. ff_vp8dsp_init(&d);
  115. randomize_buffers(src, dst, 4, coef);
  116. dct4x4(coef);
  117. for (dc = 0; dc <= 1; dc++) {
  118. void (*idct)(uint8_t *, int16_t *, ptrdiff_t) = dc ? d.vp8_idct_dc_add : d.vp8_idct_add;
  119. if (check_func(idct, "vp8_idct_%sadd", dc ? "dc_" : "")) {
  120. if (dc) {
  121. memset(subcoef0, 0, 4 * 4 * sizeof(int16_t));
  122. subcoef0[0] = coef[0];
  123. } else {
  124. memcpy(subcoef0, coef, 4 * 4 * sizeof(int16_t));
  125. }
  126. memcpy(dst0, dst, 4 * 4);
  127. memcpy(dst1, dst, 4 * 4);
  128. memcpy(subcoef1, subcoef0, 4 * 4 * sizeof(int16_t));
  129. // Note, this uses a pixel stride of 4, even though the real decoder uses a stride as a
  130. // multiple of 16. If optimizations want to take advantage of that, this test needs to be
  131. // updated to make it more like the h264dsp tests.
  132. call_ref(dst0, subcoef0, 4);
  133. call_new(dst1, subcoef1, 4);
  134. if (memcmp(dst0, dst1, 4 * 4) ||
  135. memcmp(subcoef0, subcoef1, 4 * 4 * sizeof(int16_t)))
  136. fail();
  137. bench_new(dst1, subcoef1, 4);
  138. }
  139. }
  140. }
  141. static void check_idct_dc4(void)
  142. {
  143. LOCAL_ALIGNED_16(uint8_t, src, [4 * 4 * 4]);
  144. LOCAL_ALIGNED_16(uint8_t, dst, [4 * 4 * 4]);
  145. LOCAL_ALIGNED_16(uint8_t, dst0, [4 * 4 * 4]);
  146. LOCAL_ALIGNED_16(uint8_t, dst1, [4 * 4 * 4]);
  147. LOCAL_ALIGNED_16(int16_t, coef, [4], [4 * 4]);
  148. LOCAL_ALIGNED_16(int16_t, subcoef0, [4], [4 * 4]);
  149. LOCAL_ALIGNED_16(int16_t, subcoef1, [4], [4 * 4]);
  150. VP8DSPContext d;
  151. int i, chroma;
  152. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t block[4][16], ptrdiff_t stride);
  153. ff_vp8dsp_init(&d);
  154. for (chroma = 0; chroma <= 1; chroma++) {
  155. void (*idct4dc)(uint8_t *, int16_t[4][16], ptrdiff_t) = chroma ? d.vp8_idct_dc_add4uv : d.vp8_idct_dc_add4y;
  156. if (check_func(idct4dc, "vp8_idct_dc_add4%s", chroma ? "uv" : "y")) {
  157. int stride = chroma ? 8 : 16;
  158. int w = chroma ? 2 : 4;
  159. for (i = 0; i < 4; i++) {
  160. int blockx = 4 * (i % w);
  161. int blocky = 4 * (i / w);
  162. randomize_buffers(src + stride * blocky + blockx, dst + stride * blocky + blockx, stride, coef[i]);
  163. dct4x4(coef[i]);
  164. memset(&coef[i][1], 0, 15 * sizeof(int16_t));
  165. }
  166. memcpy(dst0, dst, 4 * 4 * 4);
  167. memcpy(dst1, dst, 4 * 4 * 4);
  168. memcpy(subcoef0, coef, 4 * 4 * 4 * sizeof(int16_t));
  169. memcpy(subcoef1, coef, 4 * 4 * 4 * sizeof(int16_t));
  170. call_ref(dst0, subcoef0, stride);
  171. call_new(dst1, subcoef1, stride);
  172. if (memcmp(dst0, dst1, 4 * 4 * 4) ||
  173. memcmp(subcoef0, subcoef1, 4 * 4 * 4 * sizeof(int16_t)))
  174. fail();
  175. bench_new(dst1, subcoef1, stride);
  176. }
  177. }
  178. }
  179. static void check_luma_dc_wht(void)
  180. {
  181. LOCAL_ALIGNED_16(int16_t, dc, [4 * 4]);
  182. LOCAL_ALIGNED_16(int16_t, dc0, [4 * 4]);
  183. LOCAL_ALIGNED_16(int16_t, dc1, [4 * 4]);
  184. int16_t block[4][4][16];
  185. LOCAL_ALIGNED_16(int16_t, block0, [4], [4][16]);
  186. LOCAL_ALIGNED_16(int16_t, block1, [4], [4][16]);
  187. VP8DSPContext d;
  188. int dc_only;
  189. int blockx, blocky;
  190. declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t block[4][4][16], int16_t dc[16]);
  191. ff_vp8dsp_init(&d);
  192. for (blocky = 0; blocky < 4; blocky++) {
  193. for (blockx = 0; blockx < 4; blockx++) {
  194. uint8_t src[16], dst[16];
  195. randomize_buffers(src, dst, 4, block[blocky][blockx]);
  196. dct4x4(block[blocky][blockx]);
  197. dc[blocky * 4 + blockx] = block[blocky][blockx][0];
  198. block[blocky][blockx][0] = rnd();
  199. }
  200. }
  201. wht4x4(dc);
  202. for (dc_only = 0; dc_only <= 1; dc_only++) {
  203. void (*idct)(int16_t [4][4][16], int16_t [16]) = dc_only ? d.vp8_luma_dc_wht_dc : d.vp8_luma_dc_wht;
  204. if (check_func(idct, "vp8_luma_dc_wht%s", dc_only ? "_dc" : "")) {
  205. if (dc_only) {
  206. memset(dc0, 0, 16 * sizeof(int16_t));
  207. dc0[0] = dc[0];
  208. } else {
  209. memcpy(dc0, dc, 16 * sizeof(int16_t));
  210. }
  211. memcpy(dc1, dc0, 16 * sizeof(int16_t));
  212. memcpy(block0, block, 4 * 4 * 16 * sizeof(int16_t));
  213. memcpy(block1, block, 4 * 4 * 16 * sizeof(int16_t));
  214. call_ref(block0, dc0);
  215. call_new(block1, dc1);
  216. if (memcmp(block0, block1, 4 * 4 * 16 * sizeof(int16_t)) ||
  217. memcmp(dc0, dc1, 16 * sizeof(int16_t)))
  218. fail();
  219. bench_new(block1, dc1);
  220. }
  221. }
  222. }
  223. #define SRC_BUF_STRIDE 32
  224. #define SRC_BUF_SIZE ((size + 5) * SRC_BUF_STRIDE)
  225. // The mc subpixel interpolation filter needs the 2 previous pixels in either
  226. // direction, the +1 is to make sure the actual load addresses always are
  227. // unaligned.
  228. #define src (buf + 2 * SRC_BUF_STRIDE + 2 + 1)
  229. #undef randomize_buffers
  230. #define randomize_buffers() \
  231. do { \
  232. int k; \
  233. for (k = 0; k < SRC_BUF_SIZE; k += 4) { \
  234. AV_WN32A(buf + k, rnd()); \
  235. } \
  236. } while (0)
  237. static void check_mc(void)
  238. {
  239. LOCAL_ALIGNED_16(uint8_t, buf, [32 * 32]);
  240. LOCAL_ALIGNED_16(uint8_t, dst0, [16 * 16]);
  241. LOCAL_ALIGNED_16(uint8_t, dst1, [16 * 16]);
  242. VP8DSPContext d;
  243. int type, hsize, dx, dy;
  244. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, ptrdiff_t, uint8_t *, ptrdiff_t, int, int, int);
  245. ff_vp78dsp_init(&d);
  246. for (type = 0; type < 2; type++) {
  247. vp8_mc_func (*tab)[3][3] = type ? d.put_vp8_bilinear_pixels_tab : d.put_vp8_epel_pixels_tab;
  248. for (hsize = 0; hsize < 3; hsize++) {
  249. int size = 16 >> hsize;
  250. for (dy = 0; dy < 3; dy++) {
  251. for (dx = 0; dx < 3; dx++) {
  252. char str[100];
  253. if (dx || dy) {
  254. if (type == 0) {
  255. static const char *dx_names[] = { "", "h4", "h6" };
  256. static const char *dy_names[] = { "", "v4", "v6" };
  257. snprintf(str, sizeof(str), "epel%d_%s%s", size, dx_names[dx], dy_names[dy]);
  258. } else {
  259. snprintf(str, sizeof(str), "bilin%d_%s%s", size, dx ? "h" : "", dy ? "v" : "");
  260. }
  261. } else {
  262. snprintf(str, sizeof(str), "pixels%d", size);
  263. }
  264. if (check_func(tab[hsize][dy][dx], "vp8_put_%s", str)) {
  265. int mx, my;
  266. int i;
  267. if (type == 0) {
  268. mx = dx == 2 ? 2 + 2 * (rnd() % 3) : dx == 1 ? 1 + 2 * (rnd() % 4) : 0;
  269. my = dy == 2 ? 2 + 2 * (rnd() % 3) : dy == 1 ? 1 + 2 * (rnd() % 4) : 0;
  270. } else {
  271. mx = dx ? 1 + (rnd() % 7) : 0;
  272. my = dy ? 1 + (rnd() % 7) : 0;
  273. }
  274. randomize_buffers();
  275. for (i = -2; i <= 3; i++) {
  276. int val = (i == -1 || i == 2) ? 0 : 0xff;
  277. // Set pixels in the first row and column to the maximum pattern,
  278. // to test for potential overflows in the filter.
  279. src[i ] = val;
  280. src[i * SRC_BUF_STRIDE] = val;
  281. }
  282. call_ref(dst0, size, src, SRC_BUF_STRIDE, size, mx, my);
  283. call_new(dst1, size, src, SRC_BUF_STRIDE, size, mx, my);
  284. if (memcmp(dst0, dst1, size * size))
  285. fail();
  286. bench_new(dst1, size, src, SRC_BUF_STRIDE, size, mx, my);
  287. }
  288. }
  289. }
  290. }
  291. }
  292. }
  293. #undef randomize_buffers
  294. #define setpx(a, b, c) buf[(a) + (b) * jstride] = av_clip_uint8(c)
  295. // Set the pixel to c +/- [0,d]
  296. #define setdx(a, b, c, d) setpx(a, b, c - (d) + (rnd() % ((d) * 2 + 1)))
  297. // Set the pixel to c +/- [d,d+e] (making sure it won't be clipped)
  298. #define setdx2(a, b, o, c, d, e) setpx(a, b, o = c + ((d) + (rnd() % (e))) * (c >= 128 ? -1 : 1))
  299. static void randomize_loopfilter_buffers(int lineoff, int str,
  300. int dir, int flim_E, int flim_I,
  301. int hev_thresh, uint8_t *buf,
  302. int force_hev)
  303. {
  304. uint32_t mask = 0xff;
  305. int off = dir ? lineoff : lineoff * str;
  306. int istride = dir ? 1 : str;
  307. int jstride = dir ? str : 1;
  308. int i;
  309. for (i = 0; i < 8; i += 2) {
  310. // Row 0 will trigger hev for q0/q1, row 2 will trigger hev for p0/p1,
  311. // rows 4 and 6 will not trigger hev.
  312. // force_hev 1 will make sure all rows trigger hev, while force_hev -1
  313. // makes none of them trigger it.
  314. int idx = off + i * istride, p2, p1, p0, q0, q1, q2;
  315. setpx(idx, 0, q0 = rnd() & mask);
  316. if (i == 0 && force_hev >= 0 || force_hev > 0)
  317. setdx2(idx, 1, q1, q0, hev_thresh + 1, flim_I - hev_thresh - 1);
  318. else
  319. setdx(idx, 1, q1 = q0, hev_thresh);
  320. setdx(idx, 2, q2 = q1, flim_I);
  321. setdx(idx, 3, q2, flim_I);
  322. setdx(idx, -1, p0 = q0, flim_E >> 2);
  323. if (i == 2 && force_hev >= 0 || force_hev > 0)
  324. setdx2(idx, -2, p1, p0, hev_thresh + 1, flim_I - hev_thresh - 1);
  325. else
  326. setdx(idx, -2, p1 = p0, hev_thresh);
  327. setdx(idx, -3, p2 = p1, flim_I);
  328. setdx(idx, -4, p2, flim_I);
  329. }
  330. }
  331. // Fill the buffer with random pixels
  332. static void fill_loopfilter_buffers(uint8_t *buf, int stride, int w, int h)
  333. {
  334. int x, y;
  335. for (y = 0; y < h; y++)
  336. for (x = 0; x < w; x++)
  337. buf[y * stride + x] = rnd() & 0xff;
  338. }
  339. #define randomize_buffers(buf, lineoff, str, force_hev) \
  340. randomize_loopfilter_buffers(lineoff, str, dir, flim_E, flim_I, hev_thresh, buf, force_hev)
  341. static void check_loopfilter_16y(void)
  342. {
  343. LOCAL_ALIGNED_16(uint8_t, base0, [32 + 16 * 16]);
  344. LOCAL_ALIGNED_16(uint8_t, base1, [32 + 16 * 16]);
  345. VP8DSPContext d;
  346. int dir, edge, force_hev;
  347. int flim_E = 20, flim_I = 10, hev_thresh = 7;
  348. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, ptrdiff_t, int, int, int);
  349. ff_vp8dsp_init(&d);
  350. for (dir = 0; dir < 2; dir++) {
  351. int midoff = dir ? 4 * 16 : 4;
  352. int midoff_aligned = dir ? 4 * 16 : 16;
  353. uint8_t *buf0 = base0 + midoff_aligned;
  354. uint8_t *buf1 = base1 + midoff_aligned;
  355. for (edge = 0; edge < 2; edge++) {
  356. void (*func)(uint8_t *, ptrdiff_t, int, int, int) = NULL;
  357. switch (dir << 1 | edge) {
  358. case (0 << 1) | 0: func = d.vp8_h_loop_filter16y; break;
  359. case (1 << 1) | 0: func = d.vp8_v_loop_filter16y; break;
  360. case (0 << 1) | 1: func = d.vp8_h_loop_filter16y_inner; break;
  361. case (1 << 1) | 1: func = d.vp8_v_loop_filter16y_inner; break;
  362. }
  363. if (check_func(func, "vp8_loop_filter16y%s_%s", edge ? "_inner" : "", dir ? "v" : "h")) {
  364. for (force_hev = -1; force_hev <= 1; force_hev++) {
  365. fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16);
  366. randomize_buffers(buf0, 0, 16, force_hev);
  367. randomize_buffers(buf0, 8, 16, force_hev);
  368. memcpy(buf1 - midoff, buf0 - midoff, 16 * 16);
  369. call_ref(buf0, 16, flim_E, flim_I, hev_thresh);
  370. call_new(buf1, 16, flim_E, flim_I, hev_thresh);
  371. if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 16))
  372. fail();
  373. }
  374. fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16);
  375. randomize_buffers(buf0, 0, 16, 0);
  376. randomize_buffers(buf0, 8, 16, 0);
  377. bench_new(buf0, 16, flim_E, flim_I, hev_thresh);
  378. }
  379. }
  380. }
  381. }
  382. static void check_loopfilter_8uv(void)
  383. {
  384. LOCAL_ALIGNED_16(uint8_t, base0u, [32 + 16 * 16]);
  385. LOCAL_ALIGNED_16(uint8_t, base0v, [32 + 16 * 16]);
  386. LOCAL_ALIGNED_16(uint8_t, base1u, [32 + 16 * 16]);
  387. LOCAL_ALIGNED_16(uint8_t, base1v, [32 + 16 * 16]);
  388. VP8DSPContext d;
  389. int dir, edge, force_hev;
  390. int flim_E = 20, flim_I = 10, hev_thresh = 7;
  391. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, uint8_t *, ptrdiff_t, int, int, int);
  392. ff_vp8dsp_init(&d);
  393. for (dir = 0; dir < 2; dir++) {
  394. int midoff = dir ? 4 * 16 : 4;
  395. int midoff_aligned = dir ? 4 * 16 : 16;
  396. uint8_t *buf0u = base0u + midoff_aligned;
  397. uint8_t *buf0v = base0v + midoff_aligned;
  398. uint8_t *buf1u = base1u + midoff_aligned;
  399. uint8_t *buf1v = base1v + midoff_aligned;
  400. for (edge = 0; edge < 2; edge++) {
  401. void (*func)(uint8_t *, uint8_t *, ptrdiff_t, int, int, int) = NULL;
  402. switch (dir << 1 | edge) {
  403. case (0 << 1) | 0: func = d.vp8_h_loop_filter8uv; break;
  404. case (1 << 1) | 0: func = d.vp8_v_loop_filter8uv; break;
  405. case (0 << 1) | 1: func = d.vp8_h_loop_filter8uv_inner; break;
  406. case (1 << 1) | 1: func = d.vp8_v_loop_filter8uv_inner; break;
  407. }
  408. if (check_func(func, "vp8_loop_filter8uv%s_%s", edge ? "_inner" : "", dir ? "v" : "h")) {
  409. for (force_hev = -1; force_hev <= 1; force_hev++) {
  410. fill_loopfilter_buffers(buf0u - midoff, 16, 16, 16);
  411. fill_loopfilter_buffers(buf0v - midoff, 16, 16, 16);
  412. randomize_buffers(buf0u, 0, 16, force_hev);
  413. randomize_buffers(buf0v, 0, 16, force_hev);
  414. memcpy(buf1u - midoff, buf0u - midoff, 16 * 16);
  415. memcpy(buf1v - midoff, buf0v - midoff, 16 * 16);
  416. call_ref(buf0u, buf0v, 16, flim_E, flim_I, hev_thresh);
  417. call_new(buf1u, buf1v, 16, flim_E, flim_I, hev_thresh);
  418. if (memcmp(buf0u - midoff, buf1u - midoff, 16 * 16) ||
  419. memcmp(buf0v - midoff, buf1v - midoff, 16 * 16))
  420. fail();
  421. }
  422. fill_loopfilter_buffers(buf0u - midoff, 16, 16, 16);
  423. fill_loopfilter_buffers(buf0v - midoff, 16, 16, 16);
  424. randomize_buffers(buf0u, 0, 16, 0);
  425. randomize_buffers(buf0v, 0, 16, 0);
  426. bench_new(buf0u, buf0v, 16, flim_E, flim_I, hev_thresh);
  427. }
  428. }
  429. }
  430. }
  431. static void check_loopfilter_simple(void)
  432. {
  433. LOCAL_ALIGNED_16(uint8_t, base0, [32 + 16 * 16]);
  434. LOCAL_ALIGNED_16(uint8_t, base1, [32 + 16 * 16]);
  435. VP8DSPContext d;
  436. int dir;
  437. int flim_E = 20, flim_I = 30, hev_thresh = 0;
  438. declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, ptrdiff_t, int);
  439. ff_vp8dsp_init(&d);
  440. for (dir = 0; dir < 2; dir++) {
  441. int midoff = dir ? 4 * 16 : 4;
  442. int midoff_aligned = dir ? 4 * 16 : 16;
  443. uint8_t *buf0 = base0 + midoff_aligned;
  444. uint8_t *buf1 = base1 + midoff_aligned;
  445. void (*func)(uint8_t *, ptrdiff_t, int) = dir ? d.vp8_v_loop_filter_simple : d.vp8_h_loop_filter_simple;
  446. if (check_func(func, "vp8_loop_filter_simple_%s", dir ? "v" : "h")) {
  447. fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16);
  448. randomize_buffers(buf0, 0, 16, -1);
  449. randomize_buffers(buf0, 8, 16, -1);
  450. memcpy(buf1 - midoff, buf0 - midoff, 16 * 16);
  451. call_ref(buf0, 16, flim_E);
  452. call_new(buf1, 16, flim_E);
  453. if (memcmp(buf0 - midoff, buf1 - midoff, 16 * 16))
  454. fail();
  455. bench_new(buf0, 16, flim_E);
  456. }
  457. }
  458. }
  459. void checkasm_check_vp8dsp(void)
  460. {
  461. check_idct();
  462. check_idct_dc4();
  463. check_luma_dc_wht();
  464. report("idct");
  465. check_mc();
  466. report("mc");
  467. check_loopfilter_16y();
  468. check_loopfilter_8uv();
  469. check_loopfilter_simple();
  470. report("loopfilter");
  471. }