vp8dsp.c 20 KB

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