FFmpeg  4.4.4
vf_hflip.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
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.
8  *
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.
13  *
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.
17  */
18 
19 #include <string.h>
20 #include "checkasm.h"
21 #include "libavfilter/hflip.h"
22 #include "libavutil/intreadwrite.h"
23 #include "libavutil/mem_internal.h"
24 
25 #define WIDTH 256
26 #define WIDTH_PADDED 256 + 32
27 
28 #define randomize_buffers(buf, size) \
29  do { \
30  int j; \
31  uint8_t *tmp_buf = (uint8_t *)buf;\
32  for (j = 0; j < size; j++) \
33  tmp_buf[j] = rnd() & 0xFF; \
34  } while (0)
35 
36 static void check_hflip(int step, const char * report_name){
40  int w = WIDTH;
41  int i;
42  int step_array[4] = {1, 1, 1, 1};
43  FlipContext s;
44 
45  declare_func(void, const uint8_t *src, uint8_t *dst, int w);
46 
47  s.bayer_plus1 = 1;
48  memset(src, 0, WIDTH_PADDED);
49  memset(dst_ref, 0, WIDTH_PADDED);
50  memset(dst_new, 0, WIDTH_PADDED);
52 
53  if (step == 2) {
54  w /= 2;
55  for (i = 0; i < 4; i++)
56  step_array[i] = step;
57  }
58 
59  ff_hflip_init(&s, step_array, 4);
60 
61  if (check_func(s.flip_line[0], "hflip_%s", report_name)) {
62  for (i = 1; i < w; i++) {
63  call_ref(src + (w - 1) * step, dst_ref, i);
64  call_new(src + (w - 1) * step, dst_new, i);
65  if (memcmp(dst_ref, dst_new, i * step))
66  fail();
67  }
68  bench_new(src + (w - 1) * step, dst_new, w);
69  }
70 }
72 {
73  check_hflip(1, "byte");
74  report("hflip_byte");
75 
76  check_hflip(2, "short");
77  report("hflip_short");
78 }
uint8_t
#define s(width, name)
Definition: cbs_vp9.c:257
#define call_new(...)
Definition: checkasm.h:211
#define check_func(func,...)
Definition: checkasm.h:124
#define call_ref(...)
Definition: checkasm.h:139
#define fail()
Definition: checkasm.h:133
#define declare_func(ret,...)
Definition: checkasm.h:128
#define report
Definition: checkasm.h:136
#define bench_new(...)
Definition: checkasm.h:271
int i
Definition: input.c:407
int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
Definition: vf_hflip.c:148
uint8_t w
Definition: llviddspenc.c:39
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:136
#define WIDTH
Definition: vf_hflip.c:25
#define randomize_buffers(buf, size)
Definition: vf_hflip.c:28
static void check_hflip(int step, const char *report_name)
Definition: vf_hflip.c:36
#define WIDTH_PADDED
Definition: vf_hflip.c:26
void checkasm_check_vf_hflip(void)
Definition: vf_hflip.c:71
#define src
Definition: vp8dsp.c:255