2 * Copyright (c) 2017 James Almer
4 * This file is part of FFmpeg.
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.
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.
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.
24 #include "libavcodec/defs.h"
25 #include "libavcodec/exrdsp.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/mem_internal.h"
30 #define PADDED_BUF_SIZE BUF_SIZE+AV_INPUT_BUFFER_PADDING_SIZE*2
32 #define randomize_buffers() \
35 for (i = 0; i < BUF_SIZE; i += 4) { \
37 AV_WN32A(src + i, r); \
41 static void check_reorder_pixels(void) {
42 LOCAL_ALIGNED_32(uint8_t, src
, [PADDED_BUF_SIZE
]);
43 LOCAL_ALIGNED_32(uint8_t, dst_ref
, [PADDED_BUF_SIZE
]);
44 LOCAL_ALIGNED_32(uint8_t, dst_new
, [PADDED_BUF_SIZE
]);
46 declare_func(void, uint8_t *dst
, const uint8_t *src
, ptrdiff_t size
);
48 memset(src
, 0, PADDED_BUF_SIZE
);
49 memset(dst_ref
, 0, PADDED_BUF_SIZE
);
50 memset(dst_new
, 0, PADDED_BUF_SIZE
);
52 call_ref(dst_ref
, src
, BUF_SIZE
);
53 call_new(dst_new
, src
, BUF_SIZE
);
54 if (memcmp(dst_ref
, dst_new
, BUF_SIZE
))
56 bench_new(dst_new
, src
, BUF_SIZE
);
59 static void check_predictor(void) {
60 LOCAL_ALIGNED_32(uint8_t, src
, [PADDED_BUF_SIZE
]);
61 LOCAL_ALIGNED_32(uint8_t, dst_ref
, [PADDED_BUF_SIZE
]);
62 LOCAL_ALIGNED_32(uint8_t, dst_new
, [PADDED_BUF_SIZE
]);
64 declare_func(void, uint8_t *src
, ptrdiff_t size
);
66 memset(src
, 0, PADDED_BUF_SIZE
);
68 memcpy(dst_ref
, src
, PADDED_BUF_SIZE
);
69 memcpy(dst_new
, src
, PADDED_BUF_SIZE
);
70 call_ref(dst_ref
, BUF_SIZE
);
71 call_new(dst_new
, BUF_SIZE
);
72 if (memcmp(dst_ref
, dst_new
, BUF_SIZE
))
74 bench_new(dst_new
, BUF_SIZE
);
77 void checkasm_check_exrdsp(void)
83 if (check_func(h
.reorder_pixels
, "reorder_pixels"))
84 check_reorder_pixels();
86 report("reorder_pixels");
88 if (check_func(h
.predictor
, "predictor"))