2 * This file is part of FFmpeg.
4 * FFmpeg is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "libavfilter/hflip.h"
22 #include "libavfilter/vf_hflip_init.h"
23 #include "libavutil/intreadwrite.h"
24 #include "libavutil/mem_internal.h"
27 #define WIDTH_PADDED 256 + 32
29 #define randomize_buffers(buf, size) \
32 uint8_t *tmp_buf = (uint8_t *)buf;\
33 for (j = 0; j < size; j++) \
34 tmp_buf[j] = rnd() & 0xFF; \
37 static void check_hflip(int step
, const char * report_name
){
38 LOCAL_ALIGNED_32(uint8_t, src
, [WIDTH_PADDED
]);
39 LOCAL_ALIGNED_32(uint8_t, dst_ref
, [WIDTH_PADDED
]);
40 LOCAL_ALIGNED_32(uint8_t, dst_new
, [WIDTH_PADDED
]);
43 int step_array
[4] = {1, 1, 1, 1};
46 declare_func(void, const uint8_t *src
, uint8_t *dst
, int w
);
49 memset(src
, 0, WIDTH_PADDED
);
50 memset(dst_ref
, 0, WIDTH_PADDED
);
51 memset(dst_new
, 0, WIDTH_PADDED
);
52 randomize_buffers(src
, WIDTH_PADDED
);
56 for (i
= 0; i
< 4; i
++)
60 ff_hflip_init(&s
, step_array
, 4);
62 if (check_func(s
.flip_line
[0], "hflip_%s", report_name
)) {
63 for (i
= 1; i
< w
; i
++) {
64 call_ref(src
+ (w
- 1) * step
, dst_ref
, i
);
65 call_new(src
+ (w
- 1) * step
, dst_new
, i
);
66 if (memcmp(dst_ref
, dst_new
, i
* step
))
69 bench_new(src
+ (w
- 1) * step
, dst_new
, w
);
72 void checkasm_check_vf_hflip(void)
74 check_hflip(1, "byte");
77 check_hflip(2, "short");
78 report("hflip_short");