2 * Copyright (c) 2015 Henrik Gramner
4 * This file is part of Libav.
6 * Libav 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.
11 * Libav 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.
16 * You should have received a copy of the GNU General Public License along
17 * with Libav; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "libavcodec/bswapdsp.h"
24 #include "libavutil/common.h"
25 #include "libavutil/intreadwrite.h"
29 #define randomize_buffers()\
32 for (i = 0; i < BUF_SIZE; i += 4) {\
42 #define check_bswap(type)\
45 for (w = 0; w < BUF_SIZE/sizeof(type); w++) {\
46 int offset = (BUF_SIZE/sizeof(type) - w) & 15; /* Test various alignments */\
48 call_ref((type*)dst0+offset, (type*)src0+offset, w);\
49 call_new((type*)dst1+offset, (type*)src1+offset, w);\
50 if (memcmp(src0, src1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))\
52 bench_new((type*)dst1+offset, (type*)src1+offset, w);\
56 void checkasm_check_bswapdsp(void)
58 DECLARE_ALIGNED(16, uint8_t, src0)[BUF_SIZE];
59 DECLARE_ALIGNED(16, uint8_t, src1)[BUF_SIZE];
60 DECLARE_ALIGNED(16, uint8_t, dst0)[BUF_SIZE];
61 DECLARE_ALIGNED(16, uint8_t, dst1)[BUF_SIZE];
66 if (check_func(h.bswap_buf, "bswap_buf"))
67 check_bswap(uint32_t);
69 if (check_func(h.bswap16_buf, "bswap16_buf"))
70 check_bswap(uint16_t);